把xampp里面的apache换成nginx

转载自: http://qinyehai.com/index.php/2011/04/%E6%8A%8Axampp%E9%87%8C%E9%9D%A2%E7%9A%84apache%E6%8D%A2%E6%88%90nginx/

由于我的生产环境用的是nginx,对于一直喜欢xampp的我,自然希望把xampp改成xnmpp,跟生产环境保持一致,步骤也很简单。

下载xampp,解压缩,下载nginx,解压到xampp下。

需要改动的地方有几个,php要改为用php-cgi.exe执行,php.ini也需要做以下修改…

enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1

我在这里还帮phpmyadmin配置个虚拟主机…

server {
listen   80;
server_name  mysql.yourservername.com;

root   D:\xampplite\phpMyAdmin;

location / {
index  index.php;
}

location ~ .*\.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
}

}

再创建2个启动/关闭nginx + php cgi的批处理…

启动nginx_start.bat:

@echo off
echo Starting PHP FastCGI…
RunHiddenConsole.exe D:\xampplite\php\php-cgi.exe -b 127.0.0.1:9000 -c D:\xampplite\php\php.ini

echo Starting nginx…
cd D:\xampplite\nginx
start nginx

关闭nginx_stop.bat:

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

RunHiddenConsole.exe是把该进程后台运行的小工具。

以后启动的时候执行nginx_start.bat和mysql_start.bat,关闭执行nginx_stop.bat和mysql_stop.bat。

原文地址:https://www.cnblogs.com/meetrice/p/2707993.html