在Mac OS X 10.9上安裝nginx

1. 安裝PCRElinux

 

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

 

$ cd ~/Download $ tar xvzf pcre-8.34.tar.gz apache

$ cd pcre-8.34xcode

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

$ sudo make $ sudo installapp

 

此步驟遇到的問題:由於mac上安裝了不一樣版本的xcode致使不能安裝,找不到路徑(/Application/xcode 3.app)。後來所有刪除從新安裝,注意還要再運行一次xcode就能正常安裝。spa

2. 安裝Nginxcode

 

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

 

$ cd ~/Download $ tar xvzf nginx-1.4.4.tar.gz ssl

$ cd nginx-1.4.4

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

$ sudo make

$ sudo make install

 

此步驟可能遇到問題:

安裝 Nginx 後,啓動服務時提示啓動失敗——80端口被佔用。

因而 Google 到了下面一個可行的方法,打開終端執行下面的命令:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

若是哪天你想讓它開機啓動了,則將unload 改成 load 便可:

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

 

  lsof命令

經過list open file命令能夠查看到當前打開文件,在linux中全部事物都是以文件形式存在,包括網絡鏈接及硬件設備。

lsof -i:80

-i參數表示網絡連接,:80指明端口號,該命令會同時列出PID,方便kill

3. 運行Nginx

$ cd /usr/local/sbin

$ sudo ./nginx  或是 sudo /usr/local/sbin/nginx

訪問http://localhost

Welcome to nginx!

就說明安裝成功了。

4. 關閉Nginx

$ cd /usr/local/sbin

$ sudo ./nginx -s stop

 

參考:http://www.nginx.cn/install

相關文章
相關標籤/搜索