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.dllextension=php_gd2.dllextension=php_mbstring.dllextension=php_mysql.dllextension=php_mysqli.dllextension=php_pdo_mysql.dllextension=php_pdo_odbc.dllextension=php_pdo_sqlite.dllextension=php_xmlrpc.dll# 设置所在时区:date.timezone = Asia/Shanghai # 由于Nginx要求cgi方式的php,还要修改以下配置enable_dl = Oncgi.force_redirect = 0cgi.fix_pathinfo=1fastcgi.impersonate = 1cgi.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.iniecho 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 offecho Stopping nginx...taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit
?
?