我通常使用apache,並且想要嘗試NGINX。NGINX配置。 PHP框架與PATHINFO 404
我已經在我的ubuntu dev機器上安裝了它,並且有幾個不同的框架和站點在開發中(codeigniter,symfony,laravel等)設置和開發。
我得到的問題是,只有.php
結束的路徑工作。如果我嘗試index.php/welcome/index
它只是404s而不是加載index.php。
我與cgi.fix_pathinfo集嘗試1和0
這是我目前(許多試過)站點配置。
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /my/path;
index index.php index.html;
# Make site accessible from http://localhost/
server_name localhost;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
location ~ \.php$ {
try_files $uri =404;
# Fix for server variables that behave differently under nginx/php-fpm than typically expected
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Include the standard fastcgi_params file included with nginx
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
# Override the SCRIPT_FILENAME variable set by fastcgi_params
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Pass to upstream PHP-FPM; This must match whatever you name your upstream connection
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location/{
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
我知道,symfony還有鏈接到一個例子nginx的設置,我認爲大多數的你提到的其他框架中做的一樣好......沒你諮詢文件?此外,您的主要問題在於您正在尋找**位置**處的.php文件,以在您的位置 – prodigitalson 2013-03-09 22:49:33
中明確顯示:http://wiki.nginx.org/Codeigniter。你需要「try_files $ uri $ uri//index.php;」 – galchen 2013-03-09 22:52:16
@prodigitalson謝謝,它是導致問題的php $。現在刪除它,它工作正常。 galchen這隻會用於codeigniter和其他使用index.php(symfony不),也轉發所有的根,這是不利於發展。 – Atrox1449 2013-03-09 22:58:07