我有一个web应用程序(simpleSAML.php)包装在一个Wordpress小部件,需要服务path如下:
http://example.com/wp-content/plugins/saml-20-single-sign-on/saml/www/module.php/saml/sp/metadata.php/1
我的WordPress的nginxconfiguration工作正常,但需要服务上面的复杂path的部分没有。 它返回“文件未find”,并在nginx日志中发布“主脚本未知”错误。
这是我在vhostconfiguration中的:
server { listen 80 default; server_name *.example.com example.com; root /srv/web/wpmulti; access_log /var/log/nginx/example.access.log; error_log /var/log/nginx/example.error.log; index index.html; location / { index index.html index.htm index.php; include global/restrictions.conf; include global/wordpress-ms-subdir.conf; rewrite ^ http://example.com$request_uri permanent; } location /wp-content/plugins/saml-20-single-sign-on/saml { alias /srv/web/wpmulti/wp-content/plugins/saml-20-single-sign-on/saml/www; location ~* /saml/(?<script>.+?\.php.*)(?<pathinfo>.*)?$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_NAME /saml/$script; fastcgi_param SCRIPT_FILENAME $document_root$script; fastcgi_param PATH_INFO $pathinfo; } } location ~ /wp-content/plugins/saml-20-single-sign-on/saml(.*) { autoindex on; alias /srv/web/wpmulti/wp-content/plugins/saml-20-single-sign-on/saml/www/$1; } location ~ ^/wp-content/plugins/saml-20-single-sign-on/saml/(.*) { alias /srv/web/wpmulti/wp-content/plugins/saml-20-single-sign-on/saml/www/$1; } }
从我们办公室的简单SAMA.php安装和networking上其他人发现的旧解决scheme中,我们已经拼凑起来了。
我一直在努力研究nginx的文档,但我似乎无法find解决scheme。 什么在我的configuration中被破坏?
经过一天的头痛,我解决了这个问题。 这是修复它的虚拟主机configuration。
server { listen 80 default; server_name *.example.com example.com; root /srv/web/wpmulti; access_log /var/log/nginx/example.access.log; error_log /var/log/nginx/example.error.log; index index.html; location / { index index.html index.htm index.php; include global/restrictions.conf; include global/wordpress-ms-subdir.conf; rewrite ^ http://example.com$request_uri permanent; } location ^~ /wp-content/plugins/saml-20-single-sign-on { location ~ ^(?<script_name>.*?\.php)(?<path_info>/.*)?$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$script_name; fastcgi_param PATH_INFO $path_info; fastcgi_param PATH_TRANSLATED $document_root$path_info; fastcgi_pass unix:/var/run/php5-fpm.sock; } } }