nginx配置支援PHP
修改php.ini檔案如下:
extension_dir="php的安裝目錄/ext"
date.timezone = Asia/Shanghai
enable_dl = On
cgi.force_redirect = 1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
cgi.fix_pathinfo=1
其它配置按自己的需要修改,如mysql的配置:extension=php_mysql.dll和extension=php_mysqli.dll
啟動
php-cgi.exe -b 127.0.0.1:9001 -c "C:\wnmp\php-5.5.7-nts-Win32-VC11-x86
修改nginx配置如下:
location / {
#root html;
root D:/opensource/weixi/MF001619;
index index.php index.html index.htm ;
#訪問路徑的檔案不存在則重寫URL轉交給ThinkPHP處理
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ [^/]\.php(/|$) {
root D:/opensource/weixi/MF001619;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
include fastcgi.conf;
#設定PATH_INFO並改寫SCRIPT_FILENAME,SCRIPT_NAME伺服器環境變數
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $fastcgi_script_name2 $1;
set $path_info $2;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
}
啟動nginx,訪問http://localhost/phpinfo.php