安装homebrew
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
安装nginx
brew install nginx
查看nginx版本
nginx -v
相关文件目录
# 文档根目录
/usr/local/var/www
# 主配置文件
/usr/local/etc/nginx/nginx.conf
# 子配置文件存放目录
/usr/local/etc/nginx/servers/
nginx主配置优化
~ lingye$ cat nginx.conf
# user root;
worker_processes 1;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '"$http_x_forwarded_for" $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"';
#access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
# 防止加载不必要的配置
include /usr/local/nginx/servers/*.conf;
}
常用命令
nginx -c filepath 指定conf文件启动
nginx -s stop 停止
nginx -s quit 退出
nginx -s reopen 重新运行
nginx -s reload 热重启(无感)