【问题标题】:Using Apache on port 8081, Nginx on port 80 and UWSGI using file socket for a Django App works on port 8000 but not on port 80在端口 8081 上使用 Apache,在端口 80 上使用 Nginx,在 Django 应用程序中使用文件套接字的 UWSGI 在端口 8000 上工作,但在端口 80 上不工作
【发布时间】:2013-10-14 11:37:12
【问题描述】:

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

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

如果我将监听设置为 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

【问题讨论】:

    标签: django apache nginx cpanel uwsgi


    【解决方案1】:

    通过更改解决了问题:

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

    到:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 1970-01-01
      • 2018-01-12
      • 2019-05-27
      • 1970-01-01
      • 2018-09-23
      • 2021-12-23
      相关资源
      最近更新 更多