一、須要安裝的程序:php
(1) http服務器:nginxhtml
(2) php開發環境:phpstormnginx
(3) php安裝環境:phpsql
(4) 數據庫:postgresql數據庫
二、修改nginx/conf/nginx.conf 找到該段服務器
#location ~ \.php$ {phpstorm
# root html;post
# fastcgi_pass 127.0.0.1:9000;postgresql
# fastcgi_index index.php;orm
# 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了;