nginx

  • nignx.exe所在目录启动nginx
    1
    nginx
  • 查看所有进程信息
    1
    ps -ef | grep nginx 查看nginx所有进程信息
  • 查看端口占用情况
    1
    2
    #80表示查看80端口的
    lsof -i:80
  • 停止nignx
    1
    2
    3
    nginx -s quit   #优雅停止
    nginx -s stop #立即停止
    nginx -s reload #重载配置文件
  • 查看配置
    1
    2
    nginx -V #查看配置
    nginx -t #检查配置是否出错

nginx 基本配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
event {}

http {

include /etc/nginx/mime.types; #导入文件MIME类型
include /etc/nginx/conf.d/*.conf;

server {
listen 80;
server_name localhost;
root /dist; # 访问80端口返回root页面
index egg.html; #默认访问index.html,配置后以配置优先
}
}

location 的使用

1
2
3
4
5
6
7
server {
listen 80;
server_name localhost;
location / { # 访问根目录下的请求都从/dist目录下开始寻找资源
root /dist;
}
}
1
2
3
4
5
6
7
8
# 完全指定请求地址对应的资源地址
location = /app/index.html {
root /dist;
}
# 也可以开启正则
location ~ /videos/video[6-9].avi {
root /videos/
}