Home > Backend Development > PHP Tutorial > win7下nginx跟php的配置

win7下nginx跟php的配置

WBOY
Release: 2016-06-13 12:22:38
Original
935 people have browsed it

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; }
Copy after login

?

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 
Copy after login

?

3. 启动php的cgi

D:\server\php-5.6.10>php-cgi.exe -b 127.0.0.1:9000
Copy after login

?

4. 运行nginx

start nginx
Copy after login

?

重启Nginx:

nginx.exe -s reload
Copy after login

?

停止nginx:

nginx.exe -s stop
Copy after login

?

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
Copy after login

?

?停止文件 stop.bat

@echo offecho Stopping nginx...taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit
Copy after login

?

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template