mac下安装nginx问题解决

需要在mac上安装nginx,按照下面的博客链接一步步安装,但是碰到了些问题。下面写一下我的解决方式。

(http://stevendu.iteye.com/blog/1535466)

1. 安装PCRE 

Download latest PCRE. After download go to download directory from terminal. 

$ cd ~/Download $ tar xvzf pcre-8.12.tar.gz 

$ cd pcre-8.12 

$ sudo ./configure --prefix=/usr/local 

$ sudo make

$ sudo make  install

-------------------------------------------------------------我是华丽的分割线----------------------------------------------------------------

上面可能不会报错或者有什么异常,不过你可以先去目录/usr看下有没有local目录,如果没有这个目录,那就自己建一个local目录,按照上面的步骤操作一遍

-------------------------------------------------------------我是华丽的分割线----------------------------------------------------------------

2. 安装Nginx 

Download latest nginx from Nginx.org. After download, let install 

$ cd ~/Download $ tar xvzf nginx-1.0.0.tar.gz 

$ cd nginx-1.0.0

$ sudo ./configure --prefix=/usr/local --with-http_ssl_module --with-ld-opt="-L /usr/local/lib"

$ sudo make

$ sudo make install

报错了呢,错误如下:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre=<path> option.

那我就按照错误的提示,使用选项--without-http_rewrite_module试试:

$ sudo ./configure --prefix=/usr/local --with-http_ssl_module --with-ld-opt="-L /usr/local/lib" --without-http_rewrite_module

成功了!!! 

3. 运行Nginx

$ cd /usr/local/sbin

$ sudo ./nginx

访问http://localhost

(第一次访问http://localhost可能会失败,那么重启一下你的nginx,再访问试试呢)

成功的页面:

 

4. 关闭Nginx

$ cd /usr/local/sbin

$ sudo ./nginx -s stop

原文地址:https://www.cnblogs.com/sonofelice/p/5030886.html