1

这是我的 nginx 配置:-

user http;
worker_processes  1;

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"';

    # main access log
    access_log  /var/log/nginx_access.log  main;

    # main error log
    error_log  /var/log/nginx_error.log debug;

    # My django main site
    server {
        listen   80;
        server_name mysite.com;
        # no security problem here, since / is alway passed to upstream
        root /var/git/mysite_live;
        # serve directly - analogous for static/staticfiles
        location /static {
            alias /var/git/mysite_live/public/static;
        }
        location /media {
            alias /var/git/mysite_live/public/media;
        }
        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_connect_timeout 10;
            proxy_read_timeout 10;
            proxy_pass http://localhost:8000/;
        }
        # what to serve if upstream is not available or crashes
        error_page 500 502 503 504 /media/50x.html;
    }

    # My wordpress blog, on a subdomain
    server {
        listen       80;                    # our server's public IP address:port
        server_name  blog.mysite.com;        # our domain name
        root         /srv/http/wordpress/;  # absolute path to your WordPress installation

        try_files $uri $uri/ /index.php;

        location ~ \.php$ {
            include        fastcgi_params;
            fastcgi_pass   localhost:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

    }

}

rc.d start php-fpm我在我的 Arch linux 服务器上安装并运行了 php-fpm工作正常。

我是否遗漏了阻止 nginx 使用 php-fpm 服务器的东西——它应该在这个反向代理设置中为我位于 /srv/http/wordpress 的 wordpress 站点提供服务?

我在访问 blog.mysite.com 时收到 403 Forbidden 错误,并且在我的 nginx 错误日志中显示了相同的错误:

2012/03/03 05:09:30 [error] 26414#0: *7 directory index of "/srv/http/wordpress/" is forbidden, client: 133.235.39.138, server: blog.mysite.com, request: "GET / HTTP/1.1", host: "blog.mysite.com"  
4

1 回答 1

3

改变:

    try_files $uri $uri/ /index.php;

到:

    try_files $uri /index.php;
于 2012-03-06T22:12:26.223 回答