nginx的基本使用
1、windows环境下nginx常用命令
在nginx.exe的目录下打开命令提示符
1.1 启动nginx
start nginx
1.2 配置文件修改重装载命令
nginx -s reload
1.3 杀死全部nginx.exe进程(不会删除logs中的nginx.pid文件)
taskkill /im nginx.exe /f
taskkill /f /t /im nginx.exe
1.4 快速停止或关闭nginx(同时会删除logs中的nginx.pid文件)
nginx -s stop
1.5 完整有序的停止nginx(同时会删除logs中的nginx.pid文件)
nginx -s quit
1.6 根据名称查询 window 下的nginx 的启动进程:
tasklist /fi "imagename eq nginx.exe"
1.7 再根据端口号查询进程
netstat -ano | findstr 30090
对于nginx使用的一些理解
样例server模块
server {
listen 9003;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /t1 {
proxy_pass http://www.qw1213.com/t1;#随意编写的ip只做说明
}
}
1、静态资源的部署
静态资源可以直接部署在\nginx-1.22.0\html目录下
例如:\nginx-1.22.0\html/h5/demo.html
这样访问路径为:http://localhost:9003/h5/demo.html
意为:nginx在html下部署了静态资源,这些静态资源通过localhost:9003代理出去(此时本机是是真实部署了服务并对外发布的–》即这些本机部署的静态资源)
2、反向代理的理解
通过配置server块,来监听本机的某个端口,代理本机端口的地址到实际地址
原本访问的http://www.qw1213.com/t1/demo.html,代理到本机端口后,本机访问http://localhost:9003//t1/demo.html即可(此时本机只有nginx的监听域名为localhost,9003端口号的服务,实际是代理后的远程机提供的实际服务,本机只做监听和转发)
参考资料:
Windows本地Nginx部署WEB项目:https://blog.csdn.net/Pointer_Sky/article/details/107983856