在Imac上安装nginx

来源:互联网 发布:磁盘恢复软件免费版 编辑:程序博客网 时间:2024/06/13 13:17

概述

以下是在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 libraryinto the system, or build the OpenSSL library statically from the sourcewith 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
0 0
原创粉丝点击