同事給的NginX安裝步驟 (精簡(jiǎn)版)

1、安裝prce(重定向支持)和openssl(https支持,如果不需要https可以不安裝。)

yum -y install pcre*
yum -y install openssl*

2、下載nginx 1.7.8
wget http://nginx.org/download/nginx-1.7.8.tar.gz
(其實(shí) 只要 http://nginx.org/download/ 網(wǎng)站下載對(duì)應(yīng)的包 .tar.gz包)

3、解壓編譯安裝
tar -zxvf nginx-1.7.8.tar.gz
然后進(jìn)入目錄編譯安裝
cd nginx-1.7.8
./configure --prefix=/usr/local/nginx-1.5.1
--with-http_ssl_module --with-http_spdy_module
--with-http_stub_status_module --with-pcre
(開(kāi)發(fā)用 只要--prefix=/usr/local/nginx-1.5.1 為安裝目錄)
(其他配置參數(shù)參考http://nginx.org/en/linux_packages.html

make
make install

4、開(kāi)啟nginx進(jìn)程
/usr/local/nginx-1.7.8/sbin/nginx

重啟或關(guān)閉進(jìn)程:
/usr/local/nginx-1.7.8/sbin/nginx -s reload
/usr/local/nginx-1.7.8/sbin/nginx -s stop
/usr/local/nginx-1.7.8/sbin/nginx -t (檢測(cè)配置正確與否)

5、關(guān)閉防火墻,或者添加防火墻規(guī)則就可以測(cè)試了。(防火墻配置方式)
service iptables stop
或者編輯配置文件:
vi /etc/sysconfig/iptables
添加這樣一條開(kāi)放80端口的規(guī)則后保存:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重啟服務(wù)即可:
service iptables restart

6.nginx 配置
配置文件一般在安裝目錄/conf/下 nginx.conf 文件
簡(jiǎn)單配置
在 server {
listen: xx //xx為端口號(hào)
location {
root /home/webapps 項(xiàng)目路徑
index index.html index.html //默認(rèn)首頁(yè)
}
}

備注: linux基本的軟件安裝為解壓 編譯 安裝
還有一些包管理器 如yum apt(ubuntu)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容