3.安装nginx-1.10.1
(1)解压nginx-1.10.1.zip文件至C:wnmp
ginx,并进入该文件夹内,找到nginx.exe,鼠标双击nginx.exe,启动nginx。
进入任务管理器进程选项卡,如找到nginx.exe进程,即确认nginx已启动。
打开浏览器,在浏览器地址栏内键入:http://127.0.0.1,如看到如下图所示界面,说明nginx正常工作。
。
(2)进入C:wnmp
ginxconf文件夹内,记事本或写字板打开nginx的配置文件nginx.conf
找到如下两处进行修改,修改内容如下
server {listen 80;server_name localhost;#modify by lee 20160902 for php -slocation / {root C:/wnmp/www;index index.html index.htm index.php;}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ .php$ {root C:/wnmp/www;fastcgi_pass 127.0.0.1:9001;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}#modify by lee 20160902 for php -e}4.安装php-5.6.25-nts-Win32-VC11-x64/x86
(5)编写启动脚本 start.bat (其实到上步为止,已经配置完成,但是为了以后便于启动各种服务,特此编写一个启动脚本。)
新建文本文档,重命名为start.bat
用记事本打开后,做如下编辑:
(如果所以文件目录与本教程所述完全一致,则此脚本可以直接使用,如果有区别,则需要对NGINX_DIR和PHP_DIR做相应修改后使用)
@echo offrem the use of batecho ==================begin========================cls SET NGINX_PATH=C:SET NGINX_DIR=C:wnmp ginxSET PHP_DIR=C:wnmpphpcolor 0a TITLE Nginx ManagerCLS ECHO. ECHO. * * Nginx Manage App * ECHO. :MENU ECHO. * nginx process list * tasklist|findstr /i "nginx.exe"ECHO. ECHO. [1] start Nginx ECHO. [2] stop Nginx ECHO. [3] restart Nginx ECHO. [4] exit ECHO. ECHO.Please input the number:set /p ID=IF "%id%"=="1" GOTO start IF "%id%"=="2" GOTO stop IF "%id%"=="3" GOTO restart IF "%id%"=="4" EXITPAUSE :start call :startNginxcall :startPhpFastCGIGOTO MENU:stop call :shutdownNginxGOTO MENU:restart call :shutdownNginxcall :startNginxGOTO MENU:shutdownNginxECHO. ECHO.Stop Nginx...... taskkill /F /IM nginx.exe > nulECHO.Stopping PHP FastCGI......ECHO.OK,Stop all nginx process and php fastcgigoto :eof:startNginxECHO. ECHO.Start Nginx...... IF NOT EXIST "%NGINX_DIR%nginx.exe" ECHO "%NGINX_DIR%nginx.exe" is not exists %NGINX_PATH% cd "%NGINX_DIR%" IF EXIST "%NGINX_DIR%nginx.exe" (echo "start "" nginx.exe"start "" nginx.exe)ECHO.OKgoto :eof:startPhpFastCGIECHO. ECHO.Start PHP FastCGI......IF NOT EXIST "%PHP_DIR%php-cgi.exe" ECHO "%PHP_DIR%php-cgi.exe" is not exists %NGINX_PATH% cd "%PHP_DIR%" IF EXIST "%PHP_DIR%php-cgi.exe" (echo "start "" php-cgi.exe"start /b php-cgi.exe -b 127.0.0.1:9001 -c php.ini)ECHO.OKgoto :eof(6)测试成功
<html><head><title>test mysql+php+nginx</title></head><body><?php$link = mysqli_connect("localhost","root","root");if($link){echo "db connect success!";}else{echo "db connect failed!";}?><br><?php phpinfo();?></body></html>双击上述 start.bat脚本文件,键盘输入 1后按下回车键
打开浏览器,在浏览器地址栏内键入:http://127.0.0.1,如看到如下图所示界面,说明wnmp配置成功。
至此,WNMP配置成功!
以上所述是小编给大家介绍的windows7配置Nginx+php+mysql的详细教程,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!