Nginx安裝步驟:
一、相關(guān)組件
(1) Nginx本身
下載地址:http://nginx.org/en/download.html;提供的安裝包是Nginx-1.9.7版本。
(2) Rewrite模塊的正則表達(dá)式依賴庫pcre
下載地址:http://www.pcre.org;提供的安裝包是pcre-8.38版本。
二、安裝步驟
(1) 安裝pcre
tar -zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure
make
make install
默認(rèn)安裝到/usr/local/lib下即可;安裝完成后可以#ls -l /usr/local/lib/libpcre.so
(2) 安裝nginx
tar –zxvf nginx-1.9.7.tar.gz
cd nginx-1.9.7
./configure
make
make install
三、nginx配置
配置文件默認(rèn)在/usr/local/nginx目錄下,主要的配置文件為conf目錄下的nginx.conf。
啟動(dòng)程序文件在/usr/sbin/nginx中。
日志在/var/log/nginx中,分別是access.log和error.log。
默認(rèn)的虛擬主機(jī)的目錄設(shè)置在了/usr/share/nginx/html中。
常見配置如下:
(1) 偵聽80端口 (nginx默認(rèn)監(jiān)聽80端口)
listen 80;
(2) 服務(wù)器名稱
Server_name localhost;
(3) 默認(rèn)主頁目錄在nginx安裝目錄的html子目錄。
root html;
index index.html index.html;
四、管理nginx
(1) 啟動(dòng)
/usr/local/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正確)
(2) 停止
/usr/local/nginx/sbin/nginx -s stop
(3) 重啟
/usr/local/nginx/sbin/nginx-s reload
(4) 查看狀態(tài)
netstat -autlp| grep nginx
(5) 檢查部署正確性
訪問http://localhost/,查看是否正常啟動(dòng)。
五、常見問題
(1) 缺少pcre庫:./configure: error: the HTTP rewrite module requires the PCRE library.
解決方法:安裝pcre。
(2) 缺少openssl:./configure: error: the HTTP cache module requires md5 functions from OpenSSL library.
解決方法:安裝openssl-devel。
(3) 缺少gcc-c++和libtool:The program \'libtool\' is currently not installed. You can install it by typing:sudo apt-get install libtool
解決方法:安裝libtool和gcc-c++。
(4) 缺少zlib:./configure: error: the HTTP gzip module requires the zlib library.
解決方法:安裝zlib。
當(dāng)前名稱:Linux系統(tǒng)下Nginx服務(wù)器部署
本文URL:http://jinyejixie.com/article14/cphjge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、微信小程序、外貿(mào)建站、App開發(fā)、品牌網(wǎng)站制作、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)