Deployment tutorial check #1
Python version 3.8
django==3.0.2
gunicorn==20.0.4
demonstration of django deployment with gunicorn and nginx
Deployment tutorial check #1
Python version 3.8
django==3.0.2
gunicorn==20.0.4
#!/bin/bash
sudo apt update
sudo apt -y install software-properties-common
yes | sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt -y install python3.8
sudo apt -y install python3-pip
sudo apt-get -y install python3-venv
python3 -m venv venv
sudo apt-get -y install nginx
source venv/bin/activate
which gunicorn
will get none.)pip3 install django==3.0.2
pip3 install gunicorn==20.0.4
git clone https://github.com/ARJhe/dj_gunicorn_nginx_demo.git
mv dj_gunicorn_nginx_demo demo
cd ~/<yourprojectdir>
python3 manage.py runserver 0.0.0.0:8069
cd ~/demo
gunicorn --bind 0.0.0.0:8069 demo.wsgi
deactivate
7-1. settings.py
cd ~/demo/demo
ALLOWED_HOSTS = [ 'domain.com', '<yourserverip>', 'localhost']
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
7-2. collect static file
cd ~/<yourprojectdir>
python3 manage.py collectstatic
id
to check whether in group)sudo usermod -a -G www-data <user_name>
sudo vim /etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
sudo vim /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=<user_name>
Group=www-data # make sure your user is in this group
WorkingDirectory=/home/ubuntu/demo
ExecStart=<Path of which gunicorn > --bind unix:/run/gunicorn.sock demo.wsgi:application
[Install]
WantedBy=multi-user.target
sudo systemctl start gunicorn.socket
sudo systemctl enable gunicorn.socket
11-1. check if enable or not.
sudo systemctl status gunicorn.socket
11-2. check if run dir has a file named gunicorn.socket
file /run/gunicorn.sock
12-1.
sudo vim /etc/nginx/sites-available/demo
server {
listen 80;
server_name <domain_name> <public_IP>;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias <your_static_root_path>; # static的根目錄位置
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
12-2. link available to enable
cd /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/demo
ls -l
12-3. activate
sudo service nginx start
sudo nginx -t
sudo systemctl restart nginx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.