Php 子目录中的nginx和wordpress导致访问被拒绝

Php 子目录中的nginx和wordpress导致访问被拒绝,php,wordpress,nginx,Php,Wordpress,Nginx,我有两个rails应用程序和一个wordpress运行在同一个域上。rails应用程序运行良好,但我无法在子目录下运行wordpress。它从根开始工作 我在nginx error.log中得到以下错误。注意路径中的双字按钮,这就是问题所在,但我不知道如何解决它!真正的路径是/var/www/wordpress,而不是/var/www/wordpress/wordpress 2017/12/16 21:15:18 [error] 17341#17341: *7 FastCGI sent in s

我有两个rails应用程序和一个wordpress运行在同一个域上。rails应用程序运行良好,但我无法在子目录下运行wordpress。它从根开始工作

我在nginx error.log中得到以下错误。注意路径中的双字按钮,这就是问题所在,但我不知道如何解决它!真正的路径是/var/www/wordpress,而不是/var/www/wordpress/wordpress

2017/12/16 21:15:18 [error] 17341#17341: *7 FastCGI sent in stderr: "Access 
to the script '/var/www/wordpress/wordpress' has been denied (see 
security.limit_extensions)" while reading response header from upstream, 
client: ...
这是我的nginx配置:

server {
    server_name www.example.com;
    listen 443 ssl;
    root /var/www/first_rails_app/public;
    passenger_enabled on;
    passenger_app_root /var/www/first_rails_app/;
    passenger_document_root /var/www/first_rails_app/public;
    rails_env    production;

    index index.htm index.html;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location /wordpress {
        try_files $uri $uri/ /wordpress/index.php?$args;
        root /var/www/wordpress;
        index index.php;
        passenger_enabled off;

        location ~ .php(?|$) {
            try_files $uri =404;
            fastcgi_split_path_info ^(/wordpress)(/.*)$;
            fastcgi_pass unix:/run/php/php5.6-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            #passenger_enabled off;
        }                        
    }

    location ~ ^/second_rails_app(/.*|$) {
        alias /var/www/second_rails_app/public$1;  # <-- be sure to point to 'public'!
        passenger_base_uri /second_rails_app;
        passenger_app_root /var/www/second_rails_app/;
        passenger_document_root /var/www/second_rails_app/public;
        passenger_enabled on;
    }

    ssl_session_timeout  5m;

    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_prefer_server_ciphers   on;

    client_max_body_size 4G;
    keepalive_timeout 10;

}
服务器{
服务器名称www.example.com;
听443ssl;
root/var/www/first\u rails\u app/public;
乘客_开启;
乘客_app_root/var/www/first_rails_app/;
乘客文件根/var/www/first\u rails\u app/public;
环保生产;;
index.htm index.html;
错误\u第404/404.html页;
错误\u第500页502 503 504/50x.html;
地点/文字出版社{
试试文件$uri$uri//wordpress/index.php?$args;
root/var/www/wordpress;
index.php;
乘客侧车门开关关闭;
位置~.php(?|$){
try_files$uri=404;
fastcgi_split_path_info^(/wordpress)(/.*);
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
fastcgi_index.php;
fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
包括fastcgi_参数;
#乘客侧车门开关关闭;
}                        
}
位置~^/second_rails_应用程序(/.*.$){
别名/var/www/second_rails_app/public$1;#问题就在这里

    try_files $uri $uri/ /wordpress/index.php?$args;
    root /var/www/wordpress;
您的
try_files
行显示查找请求的文件,如果未找到,请检查它是否是目录,如果它不起作用,则提供根目录+
/wordpress/index.php?$args
,即
/var/www/wordpress/wordpress/index.php?$args

对于Wordpress,这应该是有效的


try\u files$uri$uri//index.php;

您需要编辑php fpm配置中的
安全性.limit\u扩展名
选项。它可能被配置为只允许
.php
文件