1、nginx文件的配置
路径:/etc/nginx/conf.d/
example.conf
启动:service nginx [start]/[restart]/[stop]
upstream django { # server unix:///path/to/your/mysite/mysite.sock; # for a file socket server 127.0.0.1:8000; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 8080; # the domain name it will serve for server_name django; # substitute your machine's IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Finally, send all non-media requests to the Django server. location / { uwsgi_pass django; include uwsgi_params; # the uwsgi_params file you installed } location /static{ alias /var/www/learning_web/static; } location /static/admin { alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin; } }
2、uwsgi文件的配置
在项目的根目录下面,与manage.py同目录
example_uwsgi.ini
启动:uwsgi --ini example_uwsgi.ini
# uwsgi.ini file [uwsgi] # Django-related settings # the base directory (full path) chdir = /var/www/learning_web # Django's wsgi file wsgi-file = /var/www/learning_web/learnchinese/wsgi.py # module = index.wsgi:application # the virtualenv (full path) # home = /path/to/virtualenv daemonize = /var/www/learning_web/learnchinese/uwsgi.log # process-related settings # master master = true pidfile = /tmp/learnchinese_master.pid # maximum number of worker processes processes = 1 # the socket (use the full path to be safe # socket = /home/python/ocean_monitor/ocean_monitor.sock socket = 127.0.0.1:8000 # ... with appropriate permissions - may be needed chmod-socket = 664 # clear environment on exit vacuum = true
停止:
ps -aux | grep 'ecs_uwsgi.ini' | grep -v grep |cut -c 9-15|xargs kill -9
(慎用,看清杀死的进程)