在端口8081上使用Apache,端口80上的Nginx和使用Django App的文件套接字的UWSGI在端口8000上工作但在端口80上不工作

时间:2013-10-07 19:05:41

标签: django apache nginx cpanel uwsgi

由于我们有cPanel Linux Server(Centos 6.4),我们已将其设置为在端口80上使用Nginx(使用:http://nginxcp.com/

我已经设置了UWSGI: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

如果我将listen设置为8000并使用http://example.com:8000,那么一切都按预期完美运行但是如果我使用端口80,它只显示服务器docroot文件树。

为解决此问题,我提供了任何建议或提示。

有关设置的一些信息:

netstat -tulpn |的结果grep:80

tcp        0      0 162.216.x.xx:80             0.0.0.0:*                   LISTEN      19656/nginx
tcp        0      0 162.216.x.xx:80             0.0.0.0:*                   LISTEN      19656/nginx
tcp        0      0 162.216.x.xx:80             0.0.0.0:*                   LISTEN      19656/nginx
tcp        0      0 0.0.0.0:8081                0.0.0.0:*                   LISTEN      16329/httpd

我的nginx.conf:

# the upstream component nginx needs to connect to
upstream django {
    server unix:///var/uwsgi/incitollc.sock; # for a file socket
    }

# configuration of the server

    server {
        # the port your site will be served on
        listen      80;
        # the domain name it will serve for
        server_name example.biz www.example.biz 162.216.5.82; # substitute your machine's IP address or FQDN
        root /home/example/public_html/exampleapp;
        access_log /home/example/public_html/logs/access.log;
        error_log /home/example/public_html/logs/error.log;
        charset     utf-8;

        # max upload size
        client_max_body_size 75M;   # adjust to taste

        # Django media
        location /media  {
            alias /home/example/public_html/exampleapp/media;  # your Django project's media files - amend as required
        }

        location /static {
            alias /home/example/public_html/exampleapp/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/example/public_html/uwsgi_params;
            }
        }

我的uwsgi.ini:

[uwsgi]

chdir           = /home/example/public_html/exampleapp
module          = exampleapp.wsgi:application
home        = /home/example/public_html/exampleappenv
master          = true
processes       = 10
socket      = /var/uwsgi/exampleapp.sock
chmod-socket    = 666
vacuum          = true
gid         = nobody
uid         = nobody
pidfile     = /var/uwsgi/exampleapp.pid

1 个答案:

答案 0 :(得分:0)

通过更改修复问题:

upstream django {
    server unix:///var/uwsgi/incitollc.sock; # for a file socket
    }

到:

upstream django {
    server unix:/var/uwsgi/incitollc.sock; # for a file socket
    }