安装了 nginx/django 的 Arch Linux 拒绝显示任何内容

安装了 nginx/django 的 Arch Linux 拒绝显示任何内容

我在 Amazon Ec2 上,使用 Arch Linux 服务器。虽然我真的很喜欢它,但我遇到了让 nginx 显示任何内容的问题。每次我尝试将我的主机名输入浏览器时,浏览器都会提示由于某种原因它不可用 - 就好像主机根本不存在一样。

我想知道的一件事是,我该如何启动并运行它?我是否需要进行特定的 arch linux 配置才能使其可通过网络访问?我打开了端口 80 和端口 22。我尝试过使用 gunicorn、python-flup 和 nginx。

Nginx 配置

user  http;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

   server {

    listen      80;
    server_name _;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    #charset koi8-r;

    location ^~ /media/ {
        root /path/to/media;
    }   

    location ^~ /admin-media/ {
        root /usr/lib/python2.7/site-packages/django/contrib/admin/media;
    }

    location / {

        root /path/to/root/;

        fastcgi_pass 127.0.0.1:8080;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_pass_header Authorization;
        fastcgi_intercept_errors off;
        fastcgi_index index.html;

        index index.htm index.html;
    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
        root /etc/nginx/html/50x.html;
    }

   }


   # server {
   #     listen       80;
   #     server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

  #      location / {
   #         root   html;
    #        index  index.html index.htm;
     #   }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
            root   html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    #}


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

我不知道这是服务器问题还是配置问题:我已经遵​​循了太多指南,甚至数不过来。问题是 Django 本身运行良好,我对存储站点文件的文档根目录的权限是 777。除此之外,我有一个运行良好的 git repo,django、python 和所有程序都可以正常启动。当我在文档根目录中执行 时,runfcgi情况也是如此。gunicorngunicorn_django -b 0.0.0.0:8000

以下是我的输出:

2012-04-15 05:17:37 [3124] [INFO] Starting gunicorn 0.14.2
2012-04-15 05:17:37 [3124] [INFO] Listening at: http://0.0.0.0:8081 (3124)
2012-04-15 05:17:37 [3124] [INFO] Using worker: sync
2012-04-15 05:17:37 [3127] [INFO] Booting worker with pid: 3127

据我所知,一切似乎都很好,对于 nginx 也是如此error.logaccess.log事实上,访问日志完全是空白的。

我只是觉得很迷茫;解决这样的问题,正确的方法是什么?

答案1

出于某种原因,我以为端口 80 是开放的(因为我记得之前启用过它)。问题只是它被关闭了。

因此,在本地机器上,我所做的就是输入

ec2-authorize default -p 80

其中,-p是端口指令,default是安全组的名称。

相关内容