CentOS 安裝 Nginx伺服器環境方法

來源:互聯網
上載者:User

#CentOS 安裝 Nginx 伺服器#

1、如果沒有安裝 GCC 開發工具請先安裝:yum groupinstall -y “Development Tools”

2、下載新版本的 nginx:http://nginx.org/en/download.html,
下載到本地:wget http://nginx.org/download/nginx-1.4.3.tar.gz

3、解壓源碼包:tar zxvf nginx-1.4.3.tar.gz

4、進入解壓出來的源碼檔案夾:cd nginx-1.4.3

5、配置 nginx:./configure

6、安裝時如報錯:./configure: error: the HTTP rewrite module requires the PCRE library.
輸入命令:yum install -y pcre-devel

7、安裝時如報錯:./configure: error: the HTTP gzip module requires the zlib library.
輸入命令:yum install -y zlib-devel

8、編譯 nginx:輸入命令:make

9、安裝 nginx:輸入命令:make install

10、啟動 nginx:
由於 nginx 預設安裝在 /usr/local/nginx,所以啟動時輸入:/usr/local/nginx/sbin/nginx

11、停止 nginx:/usr/local/nginx/sbin/nginx -s stop

12、重載 nginx:/usr/local/nginx/sbin/nginx -s reload

 

#配置 Nginx 後無法通過ip訪問的解決方案#

本機或區域網路無法通過 ip 訪問 Nginx 伺服器是由於 CentOS 防火牆的問題,處理如下:

/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.