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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM