一、解压php安装包,配置php.ini文件
二、nginx的安装与配置
nginx.conf文件
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #}
修改为
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root D:/phpStudy/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
root 网站的根目录,绝对地址,注意使用斜线/ 不能使用反斜线
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
命令行输入
php-cgi.exe -b 127.0.0.1:9000
start nginx.exe
三、为了管理方便,编写启动 停止脚本
start.bat
@echo off REM Windows 下无效 REM set PHP_FCGI_CHILDREN=5 REM 每个进程处理的最大请求数,或设置为 Windows 环境变量 set PHP_FCGI_MAX_REQUESTS=1000 echo Starting PHP FastCGI... REM RunHiddenConsole D:/phpdev/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/phpdev/php/php.ini RunHiddenConsole php-cgi.exe -b 127.0.0.1:9000 echo Starting nginx... REM RunHiddenConsole D:/phpdev/nginx/nginx.exe -p D:/phpdev/nginx RunHiddenConsole nginx.exe
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
restart_nginx.bat
@echo off REM 重启nginx RunHiddenConsole nginx.exe -s reload
四、nginx 常用其它命令
start nginx tasklist /fi "imagename eq nginx.exe" nginx -s stop fast shutdown nginx -s quit graceful shutdown nginx -s reload changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes nginx -s reopen re-opening log files