nginx下载启动windows版本
一、下载地址(当然是官网)
http://nginx.org/en/download.html
下载后直接解压不需要安装解压就行
(右键的cmd工具)
链接:https://pan.baidu.com/s/1FLzSlz1r0KSUbFn4lrlxkA
提取码:SLWJ
进入nginx目录 使用上面的工具后 右键就能直接打开cmd 不然还得一步一步进来
二、启动:start nginx
停止:nginx -s quit (quit是完整有序的停止nginx,并保存相关信息。)
nginx -s stop (stop是快速停止nginx,可能并不保存相关信息;)
配置文件修改重装载命令: nginx -s reload
查看版本: nginx -v
验证配置是否正确: nginx -t
重新打开日志文件:nginx -s reopen
一般都会一闪而过 然后去任务管理器中看看是否有nginx的进程 如果有就启动成功了
三、配置
config中的nginx.conf
server { listen 80;#监听的端口 server_name localhost;#监听的域名 #上面两个就是一会你访问的地址 #charset koi8-r; #access_log logs/host.access.log main; location / { # root html; # index index.html index.html; proxy_pass http://127.0.0.1:8081;#转发请求的地址 proxy_connect_timeout 600; proxy_read_timeout 600; }
或者这样
server { listen 80; server_name 你的域名; #后台服务配置,配置了这个location便可以通过http://域名/项目名字/xxxx 访问 location ^~ /项目名字 { proxy_pass http://项目地址:端口/项目名字/; proxy_set_header Host 项目地址:端口; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 location / { root html; index index.html index.htm; if (!-e $request_filename) { rewrite ^(.*)$ /index.html?s=$1 last; break; } } }