php+Nginx 安装手册
1、需要安装的程序:
(1) http服务器:nginx
(2) php开发环境:phpstorm
(3) php安装环境:php
(4) 数据库:postgresql
2、修改nginx/conf/nginx.conf 找到该段
#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;
#}
修改为:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
并修改include 为绝对路径。列: include E:/nginx-1.15.7/conf/fastcgi_params
在nginx/html 目录下新建index.php 内容如下
<?php
phpinfo();
?>
Php目录下copy文件 php.ini-development 修改为 php.ini
修改php.ini
(1) ;extension_dir =”./ext” 取消注释,并修改为绝对路径 extension_dir =”e:/php/ext”
(2) 取消注释 ;cgi.fix_pathinfo=1
(3) RunHiddenConsole.exe下载好放在nginx根目录下,将start_php.bat和stop_php.bat放在同级目录下
(4) 新建start_php.bat,修改php_home 和 nginx_home
@echo off
set php_home=E:/php
set nginx_home=E:/nginx-1.15.7
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 Starting nginx…
RunHiddenConsole %nginx_home%/nginx.exe -p %nginx_home%
(5) 新建stop_php.bat
@echo off
echo Stopping nginx…
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI…
taskkill /F /IM php-cgi.exe > nul
exit
启动nginx php: 点击 start_php.bat
停止 nginx php: 点击 stop_php.bat
成功后打开http://localhost/index.php 显示下面页面
.
以后就可以在nginx/html目录下直接放php了;