nginx环境搭建(windows)
2016-06-21 16:54
441 查看
安装nginx
下载nginx(官网)本次下载的是:nginx/Windows-1.10.1(Mainline version)
然后将zip包解压,放到指定目录。
cmd查看nginx -h 命令
D:\nginx-1.11.1>nginx.exe -h nginx version: nginx/1.11.1 Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -T : test configuration, dump it and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: NONE) -c filename : set configuration file (default: conf/nginx.conf) -g directives : set global directives out of configuration file
官网文档命令说明(链接):
nginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands: nginx -s stop fast shutdown nginx -s quit graceful shutdown nginx -s reload changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes nginx -s reopen re-opening log files
启动nginx:
D:\nginx-1.11.1>start nginx.exe
然后打开浏览器输入localhost,可以看到如下:
至此,nginx在windows上面就安装完毕了。
配置PHP的fast-cgi
官方教程(链接)下载RunHiddenConsole,并放置在指定目录,例如c:\bin。
建立bat文件:start-php-fcgi.bat。文件内容如下(php-cgi.exe目录需配置):
@ECHO OFF ECHO Starting PHP FastCGI... set PATH=C:\PHP;%PATH% c:\bin\RunHiddenConsole.exe C:\PHP\php-cgi.exe -b 127.0.0.1:9123
启动start-php-fcgi.bat文件。
配置nginx文件:nginx.conf。
修改server配置:
server { listen 80; server_name localhost; root e:; #charset koi8-r; #access_log logs/host.access.log main; location / { #root E:; index < ce9e span class="hljs-keyword">index.html index.htm index.php; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { #root E:; fastcgi_pass 127.0.0.1:9123; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#/scripts$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
在root目录建立index.php
echo "it works";
然后cmd重启nginx。
浏览器里面打开localhost,看到:
至此nginx+php配置完毕。
相关文章推荐
- .Net Core Linux centos7行—安装nginx,运行静态网站
- nginx built-in variables (nginx 内置的变量)
- Nginx日志分割
- django+nginx 搭建
- nginx地址重定向
- Nginx根据IP区分实现虚拟主机
- linux下重启nginx
- nginx 区分pc和mobile 到不同的404页面
- nginx 区分pc和mobile 到不同的404页面
- nginx 区分pc和mobile 到不同的404页面
- Nginx 在windows下注册系统服务
- 为最佳性能调优 Nginx
- nginx配置详解之location模块
- Ubuntu中Nginx的安装与配置
- nginx内置变量详解
- nginx配置详解之upstream模块
- Nginx下Redmine配置
- nginx php fpm 如何显示错误日志
- Flask + Gunicorn + Nginx 部署
- nginx部署