本篇文章主要介绍了"Windows下配置Nginx和PHP7",主要涉及到方面的内容,对于PHPjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下:
准备下载 Nginx Windows版并解压;
下载 PHP7 Windows版 并解压。配置 Nginx双击nginx.exe会闪退,但是在任务管理器中会发...
准备
下载 Nginx Windows版并解压;
下载 PHP7 Windows版 并解压。
配置 Nginx
双击nginx.exe
会闪退,但是在任务管理器中会发现其实已经启动了nginx.exe *32
,据说这是正常的。
在浏览器中输入localhost
可以看到页面就说明启动成功了。
配置文件
配置文件是conf/nginx.conf
。可以修改端口号、根目录等。
配置网站根目录
location / {
root ../www;
index index.html index.htm index.php;
}
允许列出目录
http {
include mime.types;
default_type application/octet-stream;
autoindex on; #允许列出目录
...
开启错误日志
找到
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
把前面的#
去掉即可。
配置PHP FastCGI server
找到
#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;
#}
把前面的#
去掉并修改fastcgi_param SCRIPT_FILENAME
location ~ \.php$ {
root ../www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME D:\www$fastcgi_script_name;
include fastcgi_params;
}
意思是,所有以 php 为后缀的文件都交给127.0.0.1:9000
来处理,而这里的 IP 地址和端口就是 FastCGI 进程监听的 IP 地址和端口。
需要注意的是D:\www$fastcgi_script_name;
中的D:\www
不能再用相对路径../www
了。
现在还不能访问 PHP 页面,需要开启 PHP CGI。
配置PHP7
复制一份php.ini-development
改为php.ini
,搜索cgi.fix_pathinfo=1
,把前面的分号去掉,保存。
启动php-cgi.exe
,如果弹出如下错误

即使修复了一个,还会有另一个,所以,干脆下载安装Visual C++
,如果是 Win7 则需要是 Win7 SP1