我正在尝试在django(1.8)
服务器上运行我的Nginx
项目,因为它要快得多。我可以使用uwsgi --ini
命令来设置套接字。所以我想要做的就是单独运行NGINX
想要运行我的django
项目,有没有办法做到这一点?那么uwsgi
创建的套接字在uwsgi --ini
命令结束时自动删除。
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
先谢谢你的帮助。
答案 0 :(得分:0)
你提出的问题没有意义。套接字用于nginx和uWSGI之间的通信。如果uWSGI没有运行,套接字的另一端就没有任何东西,也没有为你的应用程序提供服务。
你需要nginx和uWSGI。
答案 1 :(得分:0)
是的,我可以通过使用UWSGI EMPEROR模式自动化所有内容。 现在所有命令都可以自动执行,只需启动NGINX服务器即可。
Emperror模式:
编辑/etc/rc.local并添加:
/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data --daemonize /var/log/uwsgi-emperor.log