在linux下使用nginx,php-fpm和wordpress进行实验设置 - 获得403

时间:2012-03-03 05:30:32

标签: wordpress nginx archlinux php

这是我的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;
        }

    }

}

我安装了php-fpm并在我的arch linux服务器上运行rc.d start 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"  

1 个答案:

答案 0 :(得分:3)

变化:

    try_files $uri $uri/ /index.php;

要:

    try_files $uri /index.php;