win7下nginx和php的配置
1. 安装包准备
nginx : 从nginx.org下载nginx-1.8.0.zip
php: 从php.net下载php-5.6.10-Win32-VC11-x64.zip, php是免安装文件。
RunHiddenConsole: 用于隐藏命令行窗口
2. 配置
# java用8080端口做应用服务器,nginx反向代理到这个端口即可
php用9000端口作为fastcgi的服务端口,nginx反向代理到这个端口即可处理相关应用
nginx配置
location / { root D:\phpdir\xiuno_bbs\upload_me; index index.php index.html index.htm; } // PHP的反向代理设置, 通过fastcgi解析PHP, 当 Nginx 收到 php 文件的请求时,会自动转发到 PHP FastCGI Server location ~ \.php$ { root D:\phpdir\xiuno_bbs\upload_me; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # "$document_root"指前面的root路径 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
php配置
把php.ini-development这个文件更名为php.ini,修改php.ini文件:
# ext文件夹路径 extension_dir = " d:/php5.5.26/ext" # 上传缓存目录 upload_tmp_dir = " d:/php5.5.26/tmp" # session缓存目录 session.save_path = " d:/php5.5.26/session" # 打开外部扩展: extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll extension=php_pdo_odbc.dll extension=php_pdo_sqlite.dll extension=php_xmlrpc.dll ; 自动启动session session.auto_start=1 # 设置所在时区: date.timezone = Asia/Shanghai # 由于Nginx要求cgi方式的php,还要修改以下配置 enable_dl = On cgi.force_redirect = 0 cgi.fix_pathinfo=1 fastcgi.impersonate = 1 cgi.rfc2616_headers = 1
3. 启动php的cgi
D:\server\php-5.6.10>php-cgi.exe -b 127.0.0.1:9000
4. 运行nginx
start nginx
重启Nginx:
nginx.exe -s reload
停止nginx:
nginx.exe -s stop
5. Win7平台: 创建运行和停止脚本
启动文件 start.bat
@echo offecho Starting PHP FastCGI... D:\server\RunHiddenConsole\RunHiddenConsole.exe D:\server\php-5.6.10\php-cgi.exe -b 127.0.0.1:9000 -c D:\server\php-5.6.10\php.ini echo Starting nginx... D:\server\RunHiddenConsole\RunHiddenConsole.exe D:\server\nginx-1.8.0\nginx.exe -p D:\server\nginx-1.8.0
停止文件 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
相关推荐
Noneyes 2020-11-10
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23