[英]nginx php with wordpress at root and another app in subdirectory
I'm having some issues getting a subdirectory working on my nginx server. 我的Nginx服务器上的子目录无法正常工作。
I'm using nginx to serve a wordpress installation as the web root, and trying to run an additional php application at a subdirectory. 我正在使用nginx作为网络根目录提供wordpress安装,并尝试在子目录中运行其他php应用程序。 Wordpress runs fine, but I cannot for the life of me get the application to run in the subdirectory without a 404, 403, or "No input file specified."
Wordpress运行良好,但是我一生都无法在没有404、403或“未指定输入文件”的情况下让应用程序在子目录中运行。 error with various configurations.
各种配置错误。 I'm sure there is something obvious, but I can't seem to figure it out!
我敢肯定有些明显的东西,但是我似乎无法弄清楚!
Here is the relevant config: 这是相关的配置:
Any help would be greatly appreciated! 任何帮助将不胜感激!
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;
}
I don't know how to do it using your alias and setting $php_root. 我不知道如何使用您的别名并设置$ php_root。 I do know how to fix it if you make a symbolic link from the external folder into your wordpress-rootdirectory.
如果您从外部文件夹到wordpress-root目录建立符号链接,我知道如何解决。
So using the terminal you make a symbolic link so that your stacks-subdirectory is an actual subdirectory: 因此,使用终端可以建立符号链接,以便您的stacks-子目录是实际的子目录:
ln -s /another/path/to/usr/local/share/stacks/php /path/to/nginx/html/wordpress/stacks
As an nginx-config I would use 作为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;
}
}
Comment out 'try_files'. 注释掉“ try_files”。 Do the sub directories start to work then?
然后,子目录开始工作了吗? Perhaps it is processed before the 'location' directives are considered.
可能是在考虑“位置”指令之前对其进行了处理。 If that's the case, then move the 'try_files' into the block for 'location /'.
如果是这种情况,则将“ try_files”移到“ location /”块中。
I think that's a better place for 'try_files' anyway. 无论如何,我认为这是一个更好的“ try_files”的地方。 In the current configuration, it looks like requests for files that don't exist will all be sent to Wordpress, even if they are in the 'stacks' directory.
在当前配置中,即使不存在文件的请求看起来都将被发送到Wordpress,即使它们位于“ stacks”目录中也是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.