CentOS下安裝配置Nginx

ec3y 9年前發布 | 36K 次閱讀 Nginx Web服務器

網上很多列子,發現有些小錯誤導致安裝出現錯誤[root@localhost nginx]# make install make -f objs/Makefile install make[1]: *** [install] Error 1 make[1]: Leaving directory `/usr/local/src/nginx_1.9.0,自己矯正一下,可以成功安裝。

1、安裝說明
系統環境:CentOS-6.3
軟件:nginx-1.9.0.tar.gz
安裝方式:源碼編譯安裝
安裝位置:/usr/local/src/nginx_1.9.0
下載地址:http://nginx.org/en/download.html

2、安裝前提
在安裝nginx前,需要確保系統安裝了g++、gcc、openssl-devel、pcre-devel和zlib-devel軟件。安裝必須軟件:
安裝命令如下:
[root@localhost /]# yum install gcc-c++
[root@localhost /]# yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel

檢查系統安裝的Nginx:
[root@localhost /]# find -name nginx
./usr/local/src/nginx_1.9.0/sbin/nginx

卸載原有的Nginx:
[root@localhost /]# yum remove nginx

3、安裝
將安裝包文件上傳到 /usr/local/src/中執行以下操作:
[root@localhost /]# cd /usr/local/src
[root@localhost src]# tar -zxvf nginx-1.9.0.tar.gz
[root@localhost src]# rm -rf nginx-1.2.6.tar.gz
[root@localhost src]# cd /usr/local/src/nginx-1.9.0
[root@localhost nginx_1.9.0]# ./configure –prefix=/usr/local/nginx_1.9.0
[root@localhost nginx_1.9.0]# make && make install

4、配置
進入修改防火墻配置:
[root@localhost nginx_1.9.0]# vi /etc/sysconfig/iptables
添加配置項:
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
重啟防火墻:
[root@localhost nginx_1.9.0]# service iptables restart

5、啟動nginx
[root@localhost nginx_1.9.0]# cd /usr/local/src/nginx_1.9.0/sbin
[root@localhost sbin]# ./nginx

6、測試是否成功
瀏覽器中輸入測試地址: http://ip:80



 本文由用戶 ec3y 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!