目录
THINK
1)下载PHP,Nginx,MysqL文件
2)安装顺序 Nginx,PHP,MysqL
3)Nginx解压,测试能否正常运行,[再制作自动启动脚本]
4)PHP解压,测试运行,让Nginx能识别到PHP,加入环境变量,PHP.ini配置常规配置(eg:开启extension_dir及相关常用扩展)
5)MysqL解压,测试运行,加入环境变量,修改(设置)root密码
DO
下载
安装 (安装目录:”D:\wnmp”)
安装Nginx
- 解压到 D:\wnmp\Nginx
- 启动程序:在cmd中,进入
D:\wnmp\Nginx
,输入命令start Nginx
- 关闭程序:在任务管理器中结束Nginx.exe任务
测试:启动Nginx,在浏览器中访问http://localhost,出现欢迎界面表示Nginx正常工作
[TODO]start.bat程序
安装PHP
- 解压到 D:\wnmp\PHP
- 测试:cmd进行到安装目录,输入
PHP.exe -v
,正常会显示版本信息 - 环境变量:将“D:\wnmp\PHP”加入环境变量
- 手动启动php-cgi:(进入D:\wnmp\PHP)
php-cgi.exe -b 127.0.0.1:9000 -c PHP.ini
- TIP:PHP有CLI模式(PHP.exe),CGI模式(php-cgi.exe)等运行方式,与Nginx配合使用时需要用CGI模式运行PHP
让Nginx识别PHP
@H_301_142@location / { root html; index index.html index.htm; } #打开下面几行注释 location ~ \.PHP$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.PHP; #重要: 把 /scripts 修改成 $document_root #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } @H_301_142@<?PHP PHPinfo(); ?>安装MysqL
MysqL安装
- 解压到
D:\wnmp\MysqL
-安装(打开cmd,进入D:\wnmp\MysqL)
- 测试:cmd进行到安装(解压)目录,输入
MysqL --version
,正常会显示版本信息 - 环境变量:将
D:\wnmp\MysqL\bin
加入环境变量 - 在cmd中启停MysqL:启动
net start MysqL
和 停止net stop MysqL
MysqL设置修改初始密码
- 免密登陆(以管理员身份打开一个CMD窗口,输入命令,勿关闭)
MysqLd --skip-grant-tables
- 强制修改密码,账号是否失效
MysqL>update user set authentication_string=password('yourpassword'),password_expired='N' where user='root';
- 正式修改密码(因为:第一次修改的密码处理过期状态)
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
MysqL>set password for root@localhost=password('yourpassword');
检验
Nginx
- localhost能访问就证明成功运行
PHP-cli
MysqL
制作自动启动脚本
新建一个start.bat(stop.bat,restart.bat)文件,把下面的代码放到里面即可
启动:
停止:
@H_301_142@:停止脚本 @echo off echo Stopping Nginx... taskkill /F /IM Nginx.exe > nul echo Nginx 已停止 :换行 echo. echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul echo FastCGI 已停止 :请按任意键继续. . . pause重启(就是把停止启动合在一起):
@H_301_142@:停止脚本 @echo off echo Stopping Nginx... taskkill /F /IM Nginx.exe > nul echo Nginx 已停止 :换行 echo. echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul echo FastCGI 已停止 echo. :启动脚本 @echo off set PHP_home=./PHP_5_6_36_nts_Win32_VC11_x64 set Nginx_home=./Nginx_1-14_0 REM Windows 下无效 REM set PHP_FCGI_CHILDREN=5 REM 每个进程处理的最大请求数,或设置为 Windows 环境变量 set PHP_FCGI_MAX_REQUESTS=1000 echo Starting PHP FastCGI... RunHiddenConsole %PHP_home%/php-cgi.exe -b 127.0.0.1:9000 -c %PHP_home%/PHP.ini echo FastCGI 启动成功 echo. echo Starting Nginx... RunHiddenConsole %Nginx_home%/Nginx.exe -p %Nginx_home% echo Nginx 启动成功 echo. :echo 15秒后自动退出 :ping 0.0.0.0 -n 15 > null :请按任意键继续. . . pauseTIP
1. PHP常用扩展开启
@H_301_142@extension_dir = "D:\wnmp\PHP_5_6_36_nts_Win32_VC11_x64\ext" extension=PHP_gd2.dll extension=PHP_MysqL.dll extension=PHP_MysqLi.dll extension=PHP_pdo_MysqL.dll extension=PHP_redis.dll extension=PHP_mbstring.dl ;自己按需要添加...2. Nginx支持PHPINFO路由模式
THINK
原理:
- URL1:http://www.xsphp.com/index.php?s=index/handle/route;(模块:index,控制器:handle,方法:route)
- URL2:http://www.xsphp.com/index/handle/route
- URL2解释路由的方法叫PATHINFO
目的: