1.准备
创建安装目录D:/web,我们所有的文件都会放在这个目录下
2.下载完成会后获得如下文件,解压缩并重命名文件夹去掉版本号
php-5.4.16-Win32-VC9-x86.zip
nginx-1.10.2.zip
3.配置nginxnginx不需要额外的配置,直接运行就可以,打开命令行cmd切换到d:/web/nginx
输入start nginx后回车即可启动
浏览器中访问http://localhost/可以看到欢迎页面表示安装成功
3.配置php
在php的目录下可以找到php.ini-development文件,复制一份并将文件名修改为php.ini。然后修改配置文件内容
; extension_dir = "ext" ,删除前面的分号并修改为:extension_dir = "D:/web/php/ext"
;cgi.force_redirect = 1,删除前面的分号:cgi.force_redirect = 1
;cgi.fix_pathinfo=1,删除前面的分号:cgi.fix_pathinfo=1
;cgi.rfc2616_headers = 0,删除前面的分号:cgi.rfc2616_headers = 1
命令行下输入如下命令启动php,不报错表示启动成功。D:/web/php>php-cgi.exe -b 127.0.0.1:9000 -c D:/web/php/php.ini
4.检查nginx、php是否安装成功
在D:/web/nginx/html下新建一个phpinfo.php,加入如下内容后保存<?php phpinfo();?>
修改nginx.conf 增加server,也就是虚拟服务器server {
listen 80;
server_name www.yourdomain.com$;
root html/yourdomain;
index index.htmlindex.php;
fastcgi_intercept_errorson;
location / {
try_files $uri $uri/ =404;
}
location = /50x.html {
root html;
}
location ~ .php$ {
#try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param domain $subdomain;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
重启nginx
打开浏览器访问http://localhost/phpinfo.php
能看到php信息表示安装成功。
4.安装mysql
这个步骤根其它环境无特殊不同,如果安装过可以直接使用,未安装的可以根据mysql安装向导下一步即可。
最终安装之后的目录结构www
├── RunHiddenConsole.exe
├── nginx
│ ├── conf
│ ├── contrib
│ ├── docs
│ ├── html
│ ├── logs
│ ├── nginx.exe
│ └── temp
├── php
│ ├── dev
│ ├── ext
│ ├── extras
│ ├── glib-2.dll
│ ├── gmodule-2.dll
│ ├── icudt.dll
│ ├── icudt46.dll
│ ├── icuin.dll
│ ├── icuin46.dll
│ ├── icuio.dll
│ ├── icuio46.dll
│ ├── icule.dll
│ ├── icule46.dll
│ ├── iculx.dll
│ ├── iculx46.dll
│ ├── icutest.dll
│ ├── icutest46.dll
│ ├── icutu.dll
│ ├── icutu46.dll
│ ├── icuuc.dll
│ ├── icuuc46.dll
│ ├── install.txt
│ ├── libeay32.dll
│ ├── libenchant.dll
│ ├── libenchant_ispell.dll
│ ├── libenchant_myspell.dll
│ ├── libpq.dll
│ ├── libsasl.dll
│ ├── license.txt
│ ├── news.txt
│ ├── phar.phar.bat
│ ├── pharcommand.phar
│ ├── php-cgi.exe
│ ├── php-win.exe
│ ├── php.exe
│ ├── php.gif
│ ├── php.ini
│ ├── php.ini-development
│ ├── php.ini-production
│ ├── php5apache2_2.dll
│ ├── php5apache2_2_filter.dll
│ ├── php5apache2_3.dll
│ ├── php5nsapi.dll
│ ├── php5ts.dll
│ ├── pws-php5cgi.reg
│ ├── pws-php5isapi.reg
│ ├── readme-redist-bins.txt
│ ├── snapshot.txt
│ └── ssleay32.dll
├── readme.txt
├── start.bat
├── stop.bat
附:nginx和php的快速启动和关闭脚本
启动脚本@echooff
setphp_home=D:webwwwphp
setnginx_home=D:webwwwnginx
REMWindows 下无效
REMsetPHP_FCGI_CHILDREN=5
REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
setPHP_FCGI_MAX_REQUESTS=1000
echoStartingPHPFastCGI...
RunHiddenConsole %php_home%/php-cgi.exe -b 127.0.0.1:9000 -c %php_home%/php.ini
echoStartingnginx...
RunHiddenConsole %nginx_home%/nginx.exe -p %nginx_home%
关闭脚本@echooff
echoStoppingnginx...
taskkill /F /IMnginx.exe > nul
echoStoppingPHPFastCGI...
taskkill /F /IMphp-cgi.exe > nul
exit
遇到的问题:
如果遇到提示php不是有效的win32程序,是因为安装的微软运行时库不对2003需要使用vc9版本的php