在mac上安装nginx

概述

以下是在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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值