在Imac上安装nginx

本文详细介绍了在MacOSX10.9.2环境下安装和配置Nginx服务器的过程,包括安装PCRE和Nginx,解决安装过程中遇到的SSL模块依赖问题,以及启动和关闭Nginx服务的方法。

概述

以下是在mac os x 10.9.2 安装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、安装
2.1、在安装nginx的过程中我出现了下面这个问题
./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.意思大概就是没有找到OpenSSL library。所以就去http://www.openssl.org/source/去找到最新的OpenSSL library下载下来。
注意下载的保存路径下面有用。因为报这个错误,就不能使用
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 library的保存路径。
$ 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

开启Nginx

1、将/usr/local/nginx/sbin加入到环境变量里(如果没有添加环境变量,就不能直接使用sudo nginx,而是要使用绝对路径去访问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、付费专栏及课程。

余额充值