Nginx将根位置更改为wordpress站点

时间:2017-09-06 05:35:31

标签: php wordpress nginx

目前我在/var/www/html/wordpress下有一个Wordpress网站,/var/www/html/projects下有其他php项目。我希望我的根位置指向wordpress。这是我目前的nginx配置:

server {
    listen       80 default_server;
    server_name  _;
    set $yii_bootstrap "index.php";
    root         /var/www/html;
    client_max_body_size 2M;
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;
    location /projects/inspection/ {
        root /var/www/html;
            try_files $uri /index.php$is_args$args;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_index index.php;
            fastcgi_pass 127.0.0.1:9000;    
        }

    location /projects/ {
            root  /var/www/html;
            index  index.html $yii_bootstrap;
            try_files $uri $uri/ /$yii_bootstrap?$args /index.php$is_args$args;
        }
    location / {
        root  /var/www/html/wordpress;
        try_files $uri $uri/ =404;
        index index.php index.html index.htm;
    }       
    location ~ \.php{
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          # fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
          fastcgi_pass php-fpm;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param SCRIPT_NAME $fastcgi_script_name;
          include fastcgi_params;
      }


        error_page 404 /404.html;
            location = /40x.html {
        }

    }

但它返回404.我试图改为alias而它返回403禁止。我该怎么办呢?

0 个答案:

没有答案