我有一个名为test.py
的测试文件:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
我使用此命令运行uWSGI:
uwsgi --http :8001 --wsgi-file test.py
我可以通过转到xxxx.xxxx.xxxx.xxxx:8001
现在我正在尝试添加Nginx。这是我的文件mysite_nginx.conf
:
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 8000 default_server;
# the domain name it will serve for
server_name _;
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /static {
alias /home/wz/dispatcher/OurAwesomeDjangoApp/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/wz/dispatcher/OurAwesomeDjangoApp/uwsgi_params; # the uwsgi_params file you installed
}
}
当我去xxxx.xxxx.xxxx.xxxx
时,我看到了标准的“欢迎来到Nginx”。
但是,当我转到xxxx.xxxx.xxxx.xxxx:8000
时,我无法连接。
Django服务器可以在这个端口python manage.py runserver 0.0.0.0:8000
上工作。
uwsgi_params
出现在我的项目目录中。
我还创建了/etc/nginx/sites-enabled
我缺少什么?任何帮助表示赞赏。
编辑:
当我使用yum install nginx
安装nginx时,sites-available
中没有sites-enabled
和/etc/nginx/
个目录。
我手动创建了它们并添加了:
include /etc/nginx/sites-enabled/*;
到/etc/nginx/nginx.conf