nginx+uwsgi 部署django

安裝nginx:
sudo apt-get install nginxhtml

啓動nginx:
sudo /etc/init.d/nginx restart
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx startnginx

測試nginx:
打開瀏覽器 輸入: localhost:80 (默認80端口)瀏覽器

安裝uwsgi:
進入虛擬環境安裝: pip install uwsgiapp

測試uwsgi:
項目環境中 建立test.py文件:socket

def application(environ, start_response):
status = '200 OK'
output = 'Hello World! powerde by wsgi'
response_headers = [('Content-type', 'text/plain'),('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]測試

運行 : uwsgi --http :8001 --wsgi-file test.py
而後瀏覽器訪問 :http://127.0.0.1:8001
顯示 :Hello World! powerde by wsgiui

參考配置(/home/ysz/OnlineMx/xxx.ini)
[uwsgi]rest

http=127.0.0.1:8000

socket=127.0.0.1:8000
chdir=/home/ysz/OnlineMxserver

chmod-socket=664

master=true
processes=4
threads=2
module=OnlineMx.wsgihtm

wsgi-file=uwsgi_test.py

stats=127.0.0.1:9000

/etc/nginx/sites-enabled/default 文件以下
server {
listen 80;
server_name localhost; # substitute your machine's IP address or FQDN
client_max_body_size 75M; # adjust to taste
location /media {
alias /home/ysz/OnlineMx/uploadimage/; # your Django project's media files - amend as required
}
location /static {
alias /home/ysz/OnlineMx/staticBUSHU/; # your Django project's static files - amend as required
}
location / {
include uwsgi_params; # the uwsgi_params file you installed
uwsgi_pass 127.0.0.1:8000;
}
}

nginx 相關文章:
https://www.cnblogs.com/paul8339/tag/nginx/

參考地址:
http://www.javashuo.com/article/p-heomofwz-mu.html
http://www.cnblogs.com/jhao/p/6071790.html

相關文章
相關標籤/搜索