python django uwsgi nginx安裝 已安裝完成python/django的情況下安裝 pip install uwsgi cd /usr/share/nginx/html/ vim uwsgi.ini輸入以下內容 #uwsgi.ini file [uwsgi] # Django- ...
python django uwsgi nginx安裝已安裝完成python/django的情況下安裝pip install uwsgicd /usr/share/nginx/html/vim uwsgi.ini輸入以下內容-------------------------------------------------------------#uwsgi.ini file[uwsgi]# Django-related settings# the base directory (full path)chdir = /usr/share/nginx/html #manage.py所以目錄# Django's wsgi filemodule = project2.wsgi:application #應用程式project2下的wsgi文件# the virtualenv (full path)#home = /path/to/virtualenv# process-related settings# mastermaster = true# maximum number of worker processesprocesses = 3# the socket (use the full path to be safe)#socket = /home/myself/myself.socksocket = 127.0.0.1:8000 #以8000埠提供socket服務# ... with appropriate permissions - may be neededchmod-socket = 666chown-socket = nginx:nginx# clear environment on exitvacuum = trueenable-threads = true運行為cd /usr/share/nginx/html/uwsgi --ini ./uwsgi.iniyum install nginxcd /etc/nginx/vim nginx.conf輸入以下內容------------------------------------------------------------- upstream django { server 127.0.0.1:8000; } location /static/ { root /usr/share/nginx/html; } location / { include uwsgi_params; uwsgi_pass django; }cd /etc/systemd/system/ vim uwsgi.service[Unit]Description=uWSGI EmperorAfter=syslog.target[Service]ExecStart=/usr/bin/uwsgi --emperor /usr/share/nginx/htmlRestart=alwaysKillSignal=SIGQUITType=notifyStandardError=syslogNotifyAccess=all[Install]WantedBy=multi-user.targetsetting.py中加入STATIC_ROOT = '/usr/share/nginx/html/static/'python manage.py collectstaticsystemctl restart uwsgi.servicesystemctl restart nginx.servicesystemctl enable uwsgi.servicesystemctl enable nginx.servicehttps://www.cnblogs.com/sumoning/p/7147755.html