我试图在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之类的东西。 –