windows nginx +php 配置
2015-10-19 09:32
525 查看
windows nginx +php 配置
博客分类:nginx
PHPWindowsnginxCGIMySQL
在windows下进行nginx +php的配置比较简单:
1、首先下载安装php,版本至少要在5.0以上(主要是要PHP版本支持FastCgi方式,包含有php-cgi.exe即可 ),修改php.ini配置文件
enable_dl = On
cgi.force_redirect = 1
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
rror_reporting = E_ALL
display_errors = On
extension_dir = "C:\php\ext"
; 动态扩展,可以根据需要去掉 extension 前面的注释 ;
; 如加载 PDO, MySQL
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
2、Nginx配置PHP是以FastCgi方式配置的
3、用文本编辑功能根据打开E:\nginx1.0\conf 目录下的nginx.conf,找到
location / {
root html;
index index.html index.htm;
}
修改为
location / {
root D:/PHPWeb;
index index.php index.html index.htm;
}
找到
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#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;
#}
修改为
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME D:/PHPWeb$fastcgi_script_name;
include fastcgi_params;
}
4、启动fast-cgi
找到php的安装目录,在控制台输入以下命令
f:/php/php-cgi.exe -b 127.0.0.1:9000 -c f:/php/php.ini
5、找到nginx的安装目录,启动nginx
或者建立bat文件启动fast-cgi和nginx,
首先下载RunHiddenConsole.exe,附件提供下载
建立start_nginx.bat,输入以下内容:
@echo off
echo Starting PHP FastCGI...
RunHiddenConsole f:/php/php-cgi.exe -b 127.0.0.1:9000 -c f:/php/php.ini
echo Starting nginx...
d:/nginx1.0/nginx.exe
其中 127.0.0.1:9000 一定要和nginx.conf里的 fastcgi_pass 127.0.0.1:9000;要完全一致,否则会出现错误
建立stop_nginx.bat,输入以下内容:
@echo off
echo Stopping nginx...
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit
在配置完成后,在D:/PHPWeb的目录下新建index.php文件,内容如下:
<?php
phpinfo();
?>
在ie地址栏里输入http://localhost/index.php,如果出现php的相关信息,则配置成功
相关文章推荐
- nginx系列(八)nginx失效转移与超时处理
- nginx-apache服务器配置
- nginx学习(一)入门
- Nginx 关于 Rewrite 执行顺序详解
- 为Mac配置服务器nginx
- 使用Nginx、Nginx Plus抵御DDOS攻击
- keepalived+haproxy实现nginx与mysql负载均衡
- nginx配置文件详解
- 在Ubuntu上使用Nginx+uwsgi部署django
- LVS Nginx HAProxy 优缺点
- Nginx
- nginx + keepalived 双机热备
- nginx location 指令说明
- nginx学习链接
- Centos7 nginx安装
- Centos 6.5 搭建 nginx服务器
- Centos7下nginx源码安装
- Nginx 的安装, 环境是CentOS
- web服务器
- web服务器