先用brew安装,顺便把相关依赖给安装了,然后再用brew卸载,再以源码方式安装指定版本。
brew 方式
- 安装Command Line tools:
xcode-select --install
- 安装brew命令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install nginx
,默认安装的是最新版,不是长期维护的稳定版。不过,会自动安装 nginx 相关依赖,这是主要目的。- 安装好后,再执行
brew uninstall nginx
卸载,然后下载长期维护版本编译安装。
源码方式安装指定版本
下载指定版本,解压,进入源码目录,执行如下命令1
2sudo ./configure
sudo make install
配置示例
以下,指定网站到 spring 项目的静态资源目录1
2
3
4
5
6
7
8
9
10
11
12server {
listen 80;
server_name exam.hellojiazhang.com;
charset utf-8;
access_log logs/exam.hellojiazhang.com.access.log;
error_log logs/exam.hellojiazhang.com.error.log;
location / {
root /Users/andy/workspace/exam/src/main/resources/static;
index index.html;
}
}