0%

nginx-入门实践

入门实践

window环境nginx部署项目。

nginx-入门实践

下载

http://nginx.org/en/download.html

image-20200823214440256

修改nginx.conf

一般80端口被占用,我改为了8082端口

1
2
3
4
5
6
7
8
9
10
11
12
13
server {
listen 8082;# 80 改为了 8082
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}
# 省略...

启动

管理员身份运行nginx.exe

测试

浏览器输入localhost:8082

停止nginx

通过端口号查找进程

1
2
E:\nginx-1.10.3>netstat -aon|findstr "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 24968

杀进程失败

1
2
3
E:\nginx-1.10.3>taskkill -f -pid 24968
错误: 无法终止 PID 为 24968 的进程。
原因: 拒绝访问。

解决:任务管理器手动结束进程

image-20200823213505090

部署

将静态目录放到nginx/html下,不包含项目目录时,访问时没有项目目录。

image-20200823214145458

image-20200823214213072