# 가상환경 설정
$ virtualenv -p python3 env35
$ cd envDjango $ mkdir run
$ source bin/activate
$ pip install django gunicorn $ django-admin startproject testproject $ cd testproject $ django 작업
$ cat << EOF > gunicorn_cfg.py daemon=True bind='unix:/your/dir/env35/run/gunicorn.sock' workers=3 EOF
$ gunicorn -c gunicorn_cfg.py testproject.wsgi:application $ sudo -i # apt install nginx # cd /etc/nginx/sites-available/
# cat << EOF > testproject_conf server { listen 80; server_name ${YOUR_SERVER_NAME}; root /usr/share/nginx/html;
location = /favicon.ico { access_log off; log_not_found off; }
location /static { root root ${YOUR_PROJECT_DIR}; }
location / { include proxy_params; proxy_pass http://unix:/your/dir/env35/run/gunicorn.sock; }
error_page 404 /404.html; location = /40x.html { }
error_page 500 502 503 504 /50x.html; location = /50x.html { } } EOF # cd ../sites-enabled/ # ln -s ../sites-available/testproject_conf # nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
# nginx -s reload
|
아래에 링크에 자세한 설명
http://dveamer.github.io/backend/PythonWAS.html