常用命令
-
检查配置文件正确性
nginx -t -
重启服务
sudo nginx -s reload -
停止服务
sudo nginx -s quit|stop -
启动服务
sudo nginx -
查看进程
ps aux | grep nginx
其它
-
查找 nginx.conf 的位置
find / -name nginx.conf -
指定启动配置文件
sudo nginx -c /usr/local/nginx/conf/nginx.conf
user root owner; # 运行时的用户名
worker_processes 1; # 运行时的进程数
error_log /var/log/nginx/error.log; # 错误日志存放位置
pid /run/nginx.pid; # 设置 nginx 的 master 进程 ID 写入的位置
events {
worker_connections 1024; # 设置每个 woker 进程同时能为多少个连接提供服务
}
http {
include mime.types; # 把 mime.types 这个文件的内容加载进来
access_log /var/log/nginx/access.log main; # 指令设置了访问的日志存储的位置
index index.html index.htm; # 设置了当请求的地址里不包含特定的文件的时候,默认打开的文件
server {
server_name hezhiyi.com; # 创建基于主机名的虚拟主机
root "/Users/GZZHIYI/Documents/web"; # 配置虚拟主机的根目录
location / { ... }; # 配置 nginx 怎么样响应请求的资源
}
}
发表回复