所有php文件都会在nginx上生成404
我正在用nginx在我的服务器上安装Wordpress。 我希望获得的配置是: 在www.mydomain.com上,我希望索引包含在/webapps/sitoweb中/ 在www.mydomain.com/wordpress/我想要我的wordpress 我已经将wordpress放在/var/www/文件夹中,并且配置了nginx,您可以看到,我还没有报告我声明ssl重写规则的代码部分:所有php文件都会在nginx上生成404,php,wordpress,nginx,sysadmin,Php,Wordpress,Nginx,Sysadmin,我正在用nginx在我的服务器上安装Wordpress。 我希望获得的配置是: 在www.mydomain.com上,我希望索引包含在/webapps/sitoweb中/ 在www.mydomain.com/wordpress/我想要我的wordpress 我已经将wordpress放在/var/www/文件夹中,并且配置了nginx,您可以看到,我还没有报告我声明ssl重写规则的代码部分: server{ index index.html index.htm index.php;
server{
index index.html index.htm index.php;
listen 443;
ssl on;
location / {
alias /webapps/sitoweb/;
if ($request_uri ~* ".html") { rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;}
rewrite ^(/.+)\/$ $scheme://$host$1 permanent;
try_files $uri $uri.html $uri/ =404;
error_page 404 = /404.html;
location ~* \.html$ {
expires -1;
}
location ~* \.(css|js|gif|jpe?g|png)$ {
expires 168h;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
location /wordpress/ {
alias /var/www/;
autoindex off;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
}
}
现在如果我去:
在www.mydomain.com/index.html上,我获得了/webapps/sitoweb/[OK!]
在www.mydomain.com/wordpress/readme.html上,我可以看到/var/www/readme.html[OK!!]
在www.mydomain.com/wordpress/index.php上找不到index.php文件!!!![错误]
我强调文件index.php正确地位于目录/var/www/
我还在/webapps/sitoweb/中放了一个文件info.php,我可以在www.mydomain.com/info.php中看到它
正确显示/webapps/sitoweb/下的Ergo php文件,但找不到/var/www/中的php文件 合理地优化您的位置。在location/wordpress/的内部尝试location~^\/wordpress\/.+\.php$,仍然不工作。。。