centos6.8 安裝nginx須要編譯nginx源碼,不過沒啥大不了的,按照步驟來,確定能成功。
1.安裝必要的依賴:nginx
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.c++
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
centos