我刚刚安装了一个moodle,它的主题是这样的:
http://moodle.example.com/theme/styles.php/standard/1380191797/all
nginx没有select那个对PHP文件的调用,并且用404代替。
我目前的重写技术围绕着/index.php引用, /index.php可能过时了,但是之前它已经在很多事情上做了很多工作。 这是我目前的configuration。
server { listen 80; server_name moodle.example.com; root /websites/sbmoodle/moodle; index index.php; location / { try_files $uri $uri/ /index.php$request_uri /index.php; } location ~ \.php($|/) { try_files $uri =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name$fastcgi_path_info; fastcgi_pass unix:/var/run/php5-fpm.sock; } }
现在我看看Stack Exchange的冷光,在它的末尾( \.php($|/) ),我觉得应该抓住这些。 但是nginx仍然需要404s。 为什么?
是的,我已经testing/theme/styles.php (没有以下path),它工作正常。
RTMFM,Oli。 他们的wiki有一个适当的nginxconfiguration ,似乎工作。 这是重要的东西:
index index.html index.htm index.php; location / { try_files $uri $uri/ /index.html; } location ~ \.php { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 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; fastcgi_param SCRIPT_FILENAME $document_root$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; 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; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; }