CentOs6.5下独立安装Nginx篇
一、檢查系統是否安裝了Nginx
[root@localhost local]# find -name nginx [root@localhost local]#(如果已經安裝了nginx就卸載掉原來的)
[root@localhost local]# yum remove nginx?注意:下麵是安裝依賴包(linux源碼安裝的時候需要安裝依賴包,如果安裝了就跳過)
[root@localhost /]# yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*二、將安裝包文件上傳到/usr/local中執行以下操作
[root@localhost local]# cd /usr/local [root@localhost local]# tar -zxv -f nginx-1.6.0.tar.gz [root@localhost local]# rm -rf nginx-1.6.0.tar.gz [root@localhost local]# mv nginx-1.6.0 nginx [root@localhost local]# cd /usr/local/nginx-1.6.0 [root@localhost nginx-1.6.0]# ./configure --prefix=/usr/local/nginx [root@localhost nginx-1.6.0]# make [root@localhost nginx-1.6.0]# make install提示錯誤時:
./configure: error: the HTTP cache module requires md5 functions
?from OpenSSL library.?? You can either disable the module by using
?--without-http-cache option, or install the OpenSSL library into the system,
?or build the OpenSSL library statically from the source with nginx by using
?--with-http_ssl_module --with-openssl=<path> options.
這個因為第一次安裝nginx,缺少了依賴包,需要安裝:
[root@localhost nginx-1.6.0]# yum -y install pcre-devel openssl openssl-deve.... [root@localhost nginx-1.6.0]# ./configure --prefix=/usr/local/nginx .... [root@localhost nginx-1.6.0]#make && make install
....
?三、配置
#修改防火墻配置:
[root@localhost nginx-1.6.0]# vi + /etc/sysconfig/iptables #添加配置項 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #重啟防火墻 [root@localhost nginx-1.6.0]# service iptables restart?四、啟動
#方法1 [root@localhost nginx-1.6.0]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #方法2 [root@localhost nginx-1.6.0]# cd /usr/local/nginx/sbin [root@localhost sbin]# ./nginx 重啟: [root@localhost local]#/usr/local/nginx/sbin/nginx -t [root@localhost local]#/usr/local/nginx/sbin/nginx -s reload?
五、測試是否安裝成功
1、查看nginx的進程:
[root@localhost conf]# ps -ef | grep nginx?
2、?在瀏覽器中輸入:http://ip:端口 如果看到nginx的歡迎頁面表示安裝成功,如果頁面大不開,請關閉防火墻繼續測試
3、?關閉防火墻
(1) 重啟后永久性生效:??
????? 開啟:chkconfig iptables on??
????? 關閉:chkconfig iptables off??
(2) 即時生效,重啟后失效:?
????? 開啟:service iptables start??
????? 關閉:service iptables stop
nginx安裝好后如果需要開機重啟nginx請看 》》 linux下安裝nginx后開機啟動篇
轉載于:https://www.cnblogs.com/mayi168/p/3866278.html
總結
以上是生活随笔為你收集整理的CentOs6.5下独立安装Nginx篇的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: crm操作权限
- 下一篇: android开发之 - 圆形头像