windows nginx +php 配置
在windows下進行nginx +php的配置比較簡單:
1、首先下載安裝php,版本至少要在5.0以上(主要是要PHP版本支援FastCgi方式,包含有php-cgi.exe即可),修改php.ini設定檔
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
rror_reporting = E_ALL
display_errors = On
extension_dir = "C:\php\ext"
; 動態擴充,可以根據需要去掉 extension 前面的注釋 ;?
; 如載入 PDO, MySQL
extension=php_pdo.dll
extension=php_pdo_mysql.dll
2、Nginx配置PHP是以FastCgi方式配置的
3、用文本編輯功能根據開啟E:\nginx1.0\conf 目錄下的nginx.conf,找到
?
?
?? ? ? ?location / {
?? ? ? ? ? ?root ??html;
?? ? ? ? ? ?index ?index.html index.htm;
?? ? ? ?}
修改為
?
?
?? ? ? ?location / {
?? ? ? ? ? ?root ??D:/PHPWeb;
?? ? ? ? ? ?index ?index.php index.html index.htm;
?? ? ? ?}
找到
?
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
?? ? ? ?#
?? ? ? ?#location ~ \.php$ {
?? ? ? ?# ? ?root ? ? ? ? ? html;
?? ? ? ?# ? ?fastcgi_pass ? 127.0.0.1:9000;
?? ? ? ?# ? ?fastcgi_index ?index.php;
?? ? ? ?# ? ?fastcgi_param ?SCRIPT_FILENAME ?/scripts$fastcgi_script_name;
?? ? ? ?# ? ?include ? ? ? ?fastcgi_params;
?? ? ? ?#}
修改為
?
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
?? ? ? ?#
?? ? ? ?location ~ \.php$ {
?? ? ? ?# ? ?root ? ? ? ? ? html;
?? ? ? ? ? ?fastcgi_pass ? 127.0.0.1:9000;
?? ? ? ? ? ?fastcgi_index ?index.php;
?? ? ? ? ? fastcgi_param ?SCRIPT_FILENAME? D:/PHPWeb$fastcgi_script_name;
?? ? ? ? ? ?include ? ? ? ?fastcgi_params;
?? ? ? ?}
4、啟動fast-cgi
?找到php的安裝目錄,在控制台輸入以下命令
f:/php/php-cgi.exe -b 127.0.0.1:9000 -c f:/php/php.ini
5、找到nginx的安裝目錄,啟動nginx
或者建立batlogin"> 您還沒有登入,請您登入後再發表評論