概述
以下是在mac os x 10.11 安装nginx步骤
安装PCRE
1、Download latest PCRE.
2、安装
$ cd ~/Downloads
$ tar xvzf pcre-8.5
$ cd pcre-8.5
$ sudo ./configure --prefix=/usr/local
$ sudo make
$ sudo make install
安装Nginx
1、Download latest nginx from Nginx.org.
2、安装
$ cd ~/Downloads
$ tar xvzf nginx-1.6.0.tar.gz
$ cd nginx-1.6.0
$ sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-cc-opt="-Wno-deprecated-declarations"
$ sudo make
$ sudo make install
在进行到这一步的时候,出现错误
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
就去http://www.openssl.org/source/上下载了最新的版本。然后就不能运行上面
sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-cc-opt="-Wno-deprecated-declarations"
而是要运行
sudo ./configure --prefix=/usr/local/nginx --with-openssl=<path> --with-cc-opt="-Wno-deprecated-declarations"
其中path处是你下载的OpenSSL所放的位置。改完这个在运行就可以了。
开启Nginx
1、将/usr/local/nginx/sbin加入到环境变量里(如果没有添加环境变量,就要使用绝对路径去访问也就是输入:sudo /usr/local/nginx/sbin/nginx)
2、运行
$ sudo nginx
3、打开浏览器 http://localhost,如果看到如下界面表明nginx启动正常了
4、停止
$ sudo nginx -s stop