windows下nginx+php安裝配置

1、下載nginx http://nginx.org/en/download.html 解壓後進入目錄雙擊nginx.exe就啓動服務了 php

2、下載php http://php.net/downloads.php 解壓後進入目錄找到php.ini 配置一下
html

;extension=php_gd2.dll,刪除前面的分號:extension=php_gd2.dll
;extension=php_mbstring.dll,刪除前面的分號:extension=php_mbstring.dll
;extension=php_mysql.dll,刪除前面的分號:extension=php_mysql.dll
;extension=php_mysqli.dll,刪除前面的分號:extension=php_mysqli.dll
;extension=php_pdo_mysql.dll,刪除前面的分號:extension=php_pdo_mysql.dll
;cgi.force_redirect = 1,刪除前面的分號:cgi.force_redirect = 1
;cgi.fix_pathinfo=1,刪除前面的分號:cgi.fix_pathinfo=1
;cgi.rfc2616_headers = 0,刪除前面的分號:cgi.rfc2616_headers = 1



3、進入nginx目錄建立start_nginx.bat文件(啓動nginx服務與php-cgi)
@echo off
echo start_nginx.bat
echo Starting PHP FastCGI...

cd G:/php5618 & runhiddenconsole php-cgi.exe -b 127.0.0.1:9000 -c php.ini

echo starting nginx...

cd G:/nginx181 & start nginx.exe

exit



再建立stop_nginx.bat(關閉nginx服務與php-cgi)  mysql

@echo off
echo stop_nginx.bat
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

雙擊 stop_nginx.bat關閉,雙擊start_nginx.bat啓動 nginx


4、打開nginx/conf/nginx.conf文件,配置一個服務
sql

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
	
	server{	
		listen		8888;
		server_name localhost;
		location  / {
			root G:/www;
			index index.html index.htm index.php;
			autoindex on;
		}		
		location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  G:/www$fastcgi_script_name;
            include        fastcgi_params;
        }		
	}
}



雙擊 start_nginx.bat啓動服務,ok 正常
相關文章
相關標籤/搜索