Nginx

安装

自行编译安装

前往 nginx 开源项目官网下载源码,并自行编译安装。

安装时可能会报错缺少 pcre 这个库,可以自行去 pcre 官网(https://ftp.pcre.org/pub/pcre/)下载。

使用 brew

brew install nginx
brew services start nginx
brew services stop nginx

# 如果报错 unknown command services
# 可以执行以下命令进行升级
brew update
  • 安装目录(虚拟根目录):/usr/local/Cellar/nginx/1.17.7

  • 安装目录下的 html 目录 symlink 到:/usr/local/var/www

  • 配置文件目录:/usr/local/etc/nginx

  • 日志文件目录:/usr/local/var/log/nginx

指令

listen

alias 和 root

同样访问 www.example.com/test/index.html

gzip

log_format

日志记录的格式

access_log

指定日志记录的位置

模块

autoindex

用于展示当前访问的目录下的所有文件信息,前提是该目录下没有 index.html 文件

内置变量

  • $limit_rate_after

  • $limit_rate

  • $host

  • $remote_addr

反向代理以及缓存

可视化 access.log 工具

GoAccess

截图

Last updated

Was this helpful?