我試圖在Nginx
服務器上運行我的django(1.8)
項目,因爲它速度更快。我可以通過使用uwsgi --ini
命令來設置套接字。所以我想要做的就是單獨運行NGINX
想運行我的django
項目,有沒有辦法做到這一點?那麼當uwsgi --ini
命令結束時,由uwsgi
創建的套接字將自動移除。在Ubuntu上使用DJANGO服務NGINX
NGINX config and .ini ia as shown below :
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:///var/www/html/vir/crum/crumbs.sock;
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name .localhost.com;
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /var/www/html/alteryx_vir/crum/media;
}
location /static {
alias /var/www/html/vir/crum/static;
}
# Finally, send all non-media requests to the Django server.
location/{
uwsgi_pass django;
/var/www/html/vir/crum/uwsgi_params;
}
}
>>> uwsgi.ini file :
# mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /var/www/html/vir/crumb/
# Django's wsgi file
module = crum.wsgi
# the virtualenv (/alteryx_vir/)
home = /var/www/html/alteryx_vir/
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket =
/var/www/html/alteryx_vir/crum/crum.sock
#socket = var/run/uwsgi/crum.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
在此先感謝您的幫助。
是啊,我是小姐,然後引導thanx您的信息先生。 @丹尼爾,我怎麼能自動化。我不想運行一些命令來啓動uwsgi。希望你得到了我的觀點 –
與任何服務器進程(包括nginx本身)一樣,您可以使用發行版的進程管理器 - 例如systemd或upstart - 或supervisord之類的東西。 –