nginx php与rootpress的wordpress和子目录中的另一个应用程序

jas*_*ant 2 php nginx

我在使用nginx服务器上的子目录时遇到了一些问题.

我正在使用nginx将wordpress安装作为web根目录,并尝试在子目录中运行其他php应用程序.Wordpress运行正常,但我不能为我的生活让应用程序在没有404,403或"未指定输入文件"的子目录中运行.各种配置错误.我确信有一些明显的东西,但我似乎无法弄明白!

这是相关的配置:

任何帮助将不胜感激!

server {
listen       myserver.edu:8081;                
server_name  myserver.edu:8081;           

try_files $uri $uri/ /index.php;


location / {
    root /path/to/nginx/html/wordpress;
    index index.php;
}

location /stacks {
    alias /another/path/to/usr/local/share/stacks/php;
    index index.php;
}

location ~ \.php$ {
    set $php_root /path/to/nginx/html/wordpress;
    include        fastcgi_params;
    fastcgi_pass   localhost:8082;
    fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;
    }

location ~ \stacks.php$ {
    set $php_root /another/path/to/usr/local/share/stacks/php;
    include        fastcgi_params;
    fastcgi_pass   localhost:8082;
    fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;
    }
Run Code Online (Sandbox Code Playgroud)

Zom*_*aya 5

我不知道如何使用别名和设置$ php_root来做到这一点.如果您从外部文件夹到wordpress-rootdirectory创建符号链接,我确实知道如何解决它.

因此,使用终端,您可以创建一个符号链接,以便您的stacks-subdirectory是一个实际的子目录:

 ln -s /another/path/to/usr/local/share/stacks/php /path/to/nginx/html/wordpress/stacks
Run Code Online (Sandbox Code Playgroud)

作为一个nginx-config我会用

server {
    listen       myserver.edu:8081;                
    server_name  myserver.edu:8081;

    root /path/to/nginx/html/wordpress;
    index index.php;       

    location / {    
        try_files $uri $uri/ /index.php;
    }

    location /stacks {
        try_files $uri $uri/ /stacks/index.php;
    }

    location ~ \.php$ {
        fastcgi_pass   localhost:8082;
        include        fastcgi_params;
    }
}
Run Code Online (Sandbox Code Playgroud)