win 下 nginx 与 php的配置

时间:2021-10-27 06:19:52

win 下 nginx 与 php的配置

 

2、下载好后,分别把压缩包解压放入D:/nmp下。

win 下 nginx 与 php的配置

 

3、把php54下的php.ini-development文件复制一份,,改名为php.ini

 

4、修改php.ini如下:

extension_dir = "D:/nmp/php54/ext" session.save_path = "D:/nmp/php54/tmp" extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll date.timezone = PRC enable_dl = On cgi.force_redirect = 0 cgi.fix_pathinfo=1 fastcgi.impersonate = 1 cgi.rfc2616_headers = 1

5、修改nginx18下conf/nginx.conf文件

listen 80; server_name localhost; #设置编码 charset utf-8; location / { #设置网站根目录 root D:/wwwroot; #添加index.php index index.html index.htm index.php; }

location ~ \.php$ { #设置为网站根目录 root D:/wwwroot; #fastcgi监听的端口,与php的cgi启动时指定的要一致 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #$document_root就是指前面root所指的站点路径 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

6、配置好后需要运行php的cgi,在cmd中输入:

> php-cgi.exe -b 127.0.0.1:9000 -c D:/nmp/php54/php.ini

(*要进入php54的目录下)

 

7、启动nginx

> nginx.exe -p D:/nmp/nginx18

(*进入nginx18下)

stop是快速停止nginx,可能并不保存相关信息

> nginx.exe -s stop