centos6.8 安裝nginx需要編譯nginx源碼,不過沒啥大不了的,按照步驟來,肯定能成功。
1.安裝必要的依賴:
yum install -y gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
2.下載nginx源碼並編譯:nginx下載地址可以取官網找。我這是當前的最新版,1.13.
wget http://nginx.org/download/nginx-1.13.5.tar.gz
tar zxvf nginx-1.13.5.tar.gz
cd nginx-1.13.5
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre
make && make install
iptables -F(不然無法遠程訪問)
3.編譯完成後,我們去啓動nginx
通過命令 whereis nginx
,查看nginx的安裝目錄,可以看到路徑是nginx: /usr/local/nginx
然後cd /usr/local/nginx/sbin
執行命令 ./nginx
這樣就把nginx啓動起來了。
然後在瀏覽器裏直接訪問localhost,或者訪問你的服務器ip。就可以看到nginx的歡迎頁了。
關閉nginx,執行命令 ./nginx -s stop
重啓nginx,執行命令 ./nginx -s reload