詳解Linux下安裝配置Nginx

來源:互聯網
上載者:User

標籤:應用伺服器   反向 Proxy   nginx   appserver   

    1. 從Nginx官網下載Nginx。目前最新的穩定版為:1.6.2.


    2. 將下載下來的Nginx上傳到/opt/nginx目錄下。運行“tar -zxvf nginx-1.6.2.tar.gz”進行解壓。


    3. 切換到/opt/nginx/nginx-1.6.2目錄下,運行./configure進行初始化配置。如出現下面的提示,說明該機器沒有安裝PCRE,而Nginx需要依賴PCRE,需要手動安裝PCRE。


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5B/3A/wKioL1UCq8rA4B5TAAFRDt9TL9Y187.jpg" title="PCRE-01.png" alt="wKioL1UCq8rA4B5TAAFRDt9TL9Y187.jpg" />


    4. 安裝完PCRE後,再次運行./configure進行初始化即可。注意這裡產生的設定檔,尤其箭頭所指的方向,是啟動nginx時的路徑。


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/3A/wKioL1UCq-DyvhY2AAKFRqrv8WY142.jpg" title="Nginx.png" alt="wKioL1UCq-DyvhY2AAKFRqrv8WY142.jpg" />


    5. 運行 make install 進行編譯。


    6. 切換到步驟4產生的nginx運行目錄下,運行./nginx,啟動Nginx。


    如出現下面所述的錯誤,在已安裝PCRE庫的情況下,需要配置PCRE共用庫。具體操作看這裡。


./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory


    7.   在瀏覽器中輸入IP:連接埠號碼,出現如所示,說明安裝成功。


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/5B/40/wKiom1UCqzjxdL27AAITaeNRmtQ100.jpg" title="nginx-server.png" alt="wKiom1UCqzjxdL27AAITaeNRmtQ100.jpg" />


    如出現nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)。可能是連接埠號碼被佔用,切換到/usr/local/nginx/conf/目錄下,更改nginx.conf下的連接埠號碼。也有可能是不小心nginx重啟了多次,關閉nginx進程,重啟即可。


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5B/3A/wKioL1UCrG-SlNYqAAF0qrZB6zY391.jpg" title="nginx-config.png" alt="wKioL1UCrG-SlNYqAAF0qrZB6zY391.jpg" />



    8. 關閉Nginx


    使用 ps -ef|grep nginx 查看nginx的進程,可以看到nginx有兩個進程:


[[email protected] sbin]# ps -ef|grep nginx root      7276     1  0 14:21 ?        00:00:00 nginx: master process ./nginxwww       7277  7276  0 14:21 ?        00:00:00 nginx: worker processroot      7279  5197  0 14:21 pts/1    00:00:00 grep nginx


    8.1 從容停止nginx


 kill - QUIT nginx 主進程號


    8.2 停止nginx所有進程


[[email protected] sbin]# pkill -9 nginx




本文出自 “塵風隨影的天空” 部落格,請務必保留此出處http://favccxx.blog.51cto.com/2890523/1620159

詳解Linux下安裝配置Nginx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.