Php 在Nginx后面的子目录中托管Wordpress
我正在尝试在处主持wordpress安装,并已遵循处的指南,但对于任何请求,我仍然会收到“未指定输入文件” 在PHP fpm中使用Nginx 1.2.1和PHP5.3.6 以下是Nginx配置文件:Php 在Nginx后面的子目录中托管Wordpress,php,wordpress,nginx,Php,Wordpress,Nginx,我正在尝试在处主持wordpress安装,并已遵循处的指南,但对于任何请求,我仍然会收到“未指定输入文件” 在PHP fpm中使用Nginx 1.2.1和PHP5.3.6 以下是Nginx配置文件: upstream wptest { server 127.0.0.1:9000; } server { listen 80; server_name mydomain.com; access_log logs/access.log; error_log logs/error.
upstream wptest {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name mydomain.com;
access_log logs/access.log;
error_log logs/error.log;
location /blogtest {
access_log logs/blogtest.access.log;
error_log logs/blogtest.error.log;
root /opt/myblogwp;
index index.php;
try_files $uri $uri/ /blogtest/index.php;
}
location ~ \.php$ {
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_split_path_info ^(/blogtest)(/.*)$;
fastcgi_intercept_errors on;
fastcgi_pass wptest;
}
}
这是我的fastcgi_参数文件:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# Next line added by AdamJT for php-fpm
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#Concrete5 fix by AdamJT
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
我还编辑了/usr/local/php/lib/php.ini以设置cgi.fix_pathinfo=0 请记住,
location/blogtest{}
意味着您的文件将在
/opt/myblogwp/blogtest
这是你的wp站点的根目录吗?您可能需要使用别名
,而不是位置
。Alias允许将虚拟目录/somedir/设置为根目录为/opt/someotherdir/。
另外,我不太熟悉fastcgi\u split\u path\u info
,但似乎缺少一些东西。
看看这个例子:
Here's an example. The script show.php receives as argument the string article/0001. The following configuration will handle path splitting properly:
location ~ ^.+\.php {
(...)
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
(...)
}
Requesting /show.php/article/0001 sets SCRIPT_FILENAME to /path/to/php/show.php and PATH_INFO to /article/0001.
举个例子-我看不出您是如何设置实际路径信息和脚本文件名的-您使用的是默认值。。。我想你必须稍微调整一下这些参数。您得到的错误是未指定输入文件
。这意味着没有脚本文件名被传递给PHP。因此,您应该跟踪并修复路径信息和脚本文件名,以便最终得到如下结果:
/path/to/wpresssite/index.php$fastcgi_script_name
别名只能在位置内部使用,不能作为其替代品。当我用别名替换root时,也会出现同样的错误。如何跟踪路径信息和脚本文件名?我对PHP不太熟悉,实际上,当我需要运行PHP站点时,我使用的是uwsgi。您使用什么FCGI服务器-127.0.0.1:9000上正在侦听什么?尝试启用一些详细的日志-如果您可以转储所有FCGI参数-我想这就足以找出问题所在。同时尝试将PATH_INFO设置为静态路径(指向WP站点),并尝试调整SCRIPT_FILENAME值。