zoukankan      html  css  js  c++  java
  • 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后开机启动篇

  • 相关阅读:
    1058 A+B in Hogwarts (20)
    1046 Shortest Distance (20)
    1061 Dating (20)
    1041 Be Unique (20)
    1015 Reversible Primes (20)(20 分)
    pat 1027 Colors in Mars (20)
    PAT 1008 Elevator (20)
    操作系统 死锁
    Ajax的get方式传值 避免& 与= 号
    让IE浏览器支持CSS3表现
  • 原文地址:https://www.cnblogs.com/mayi168/p/3866278.html
Copyright © 2011-2022 走看看