linux CentOS7 下 Nginx1.13.7 安裝__linux

來源:互聯網
上載者:User

軟體環境:centos7 nginx-1.13.7

nginx下載地址:http://nginx.org/en/download.html 一、安裝依賴軟體

yum -y install gcc gcc-c++ autoconf automake make

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel 二、安裝nginx

//下載軟體

wget http://nginx.org/download/nginx-1.13.7.tar.gz

//解壓

tar zxvf nginx-1.13.7.tar.gz

//建立安裝目錄

mkdir -p /usr/local/nginx

//修改配置

cd nginx-1.13.7/

./configure --prefix=/usr/local/nginx  

//安裝

make && make install

三、啟動

進入安裝目錄

cd /usr/local/nginx/sbin

啟動

./nginx    

這時候在安裝機器就可以輸入地址查看了。

如果遠端存取的話需要關閉防火牆或者將80連接埠開放,添加新連接埠後需要reload 防火牆。 關閉防火牆:

CentOS 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆步驟。

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall開機啟動

firewall-cmd --state #查看預設防火牆狀態(關閉後顯示notrunning,開啟後顯示running)


開放連接埠:

添加  firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,沒有此參數重啟後失效)

重新載入 firewall-cmd --reload

查看 firewall-cmd --zone= public --query-port=80/tcp

刪除 firewall-cmd --zone= public --remove-port=80/tcp --permanent


輸入地址後出現如下表示安裝成功了。


四、解決連接埠衝突


安裝後如出現上圖資訊表示nginx連接埠與其他軟體連接埠衝突,解決辦法建議修改連接埠。

方法一、停止佔用80連接埠的程式,具體自行查詢。

方法二、修改nginx.conf檔案中nginx連接埠號碼。

cd /usr/local/nginx/conf 進入目錄

vim nginx.conf 開啟檔案

找到listen位置,將預設80連接埠修改為未被佔用連接埠。

按esc,:wq儲存退出.

再次啟動nginx即可。

 #access_log  logs/access.log  main;    sendfile        on;    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65;    #gzip  on;    server {        listen      88;        server_name  localhost;        #charset koi8-r;        #access_log  logs/host.access.log  main;

相關文章

聯繫我們

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