zoukankan      html  css  js  c++  java
  • nginx for linux安装及安装错误解决

    nginx:下载地址:http://www.nginx.org/

    1.GCC编译器

            安装指令 :yum  install -y  gcc    

            如果你所使用的是ubuntu,则安装指令为:apt-get install -y  gcc        因为ubuntu可不用yum,下同哦..............

            如果涉及到C++来编写Nginx HTTP模块,则还需要安装G++编译器

            安装指令:yum install -y gcc-c++

    2. PCRE库

            首先我们需要下载PCRE,这个步骤简单,我们可以自行完成。例如这里我们下载的安装包为pcre-8.34.tar.gz,我们需要用到移动到指定的文件夹下面,然后解压安装。

          移动指令:mv “指定文件目录”  “目标文件目录”。假设我们需要将源码移动到/home目录下 mv  /home  "源码所在目录/pcre-8.34.tar.gz"

          解压指令:tar zxvf pcre-8.34.tar.gz   然后执行如下指令。

          cd /home/pcre-8.34

          ./configure  此过程中会生成一大堆文件,不用去管它。

          make

          make install

    3.OpenSSL开发库

         yum  install -y openssl openssl-devel  

         如果是ubuntu系统,安装指令:# sudo apt-get install openssl # sudo apt-get install libssl-dev

    OK,准备工作已经做完,我们来安装Nginx。首先得下载源码,然后将其移动到目标文件夹,当然也可以就地解压。这里我们以nginx-1.6.0.tar.gz,移动到/home目录下来进行实例说明。cd到/home目录,解压。

          # tar zxvf nginx-1.6.0.tar.gz

          # cd nginx-1.6.0

          ./configure --prefix=/usr/local/nginx --with-http_stub_status_module

    make

    make install

    如果在make的时候出现make: *** 没有规则可以创建“default”需要的目标“build”这种提示,请回到OpenSSL开发库的安装上去,一般是这一步出了问题。而且你肯定没有注意./configure时候的错误提示:

    ./configure: error: the HTTP cache module requires md5 functionsfrom 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= options.

    如果一切都没有问题,我们来检查下安装是否成功。

      cd  /usr/local/nginx/sbin

          ./nginx -t 

          结果显示:

          nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

          nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

    则表示安装正确,现在我们来启动Nginx:

    cd  /usr/local/nginx/sbin

    ./nginx 启动 nginx

    这个时候打开浏览器,输入自己电脑的ip。对于不知道自己电脑ip的童靴,可以使用ifconfig指令进行查看。

    这里我在浏览器中输入:http://127.0.0.1 出现如下信息:

    看到上面nginx 欢迎界面说明启动成功

              停止nginx: pkill -9 nginx

    参考:http://www.th7.cn/system/lin/201406/61021.shtml

    出现问题:Nginx: error while loading shared libraries: libpcre.so.1

    Shell代码  
    [ew69@localhost conf]# /usr/local/nginx/sbin/nginx  
    /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory  
     
    确认已经安装PCRE: 
    Shell代码  
    [ew69@SCLABHADOOP01 lib]$ cd /lib  
    [ew69@SCLABHADOOP01 lib]$ ls *pcre*  
    libpcre.so.0  libpcre.so.0.0.1  
    [hadoop@SCLABCLUS01 nginx]$ find / -type f -name *libpcre.so.*   
    添加软链接:
    Shell代码  
    [ew69@SCLABHADOOP01 lib]$ ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1  
    前面在一般的linux上可以解决此问题.
     
    注: 在有的操作系统上面,安装pcre后,安装的位置为/usr/local/lib/*pcre*
    在redhat 64位机器之上有这样的情况.
    在redhat 64位机器上, nginx可能读取的pcre文件为/lib64/libpcre.so.1文件.
    所以在改用下面的软连接:
    Shell代码  
    [hadoop@SCLABHADOOP01 ~]$ ln -s /usr/local/lib/libpcre.so.1 /lib64/ 
     
    新手初学呀!多方借鉴!
  • 相关阅读:
    less的安装使用
    bootStrap
    响应式布局——媒体查询
    发光渐变器
    好看的按钮
    CSS3:2D、3D属性
    CSS3渐变
    background
    过渡transition、opacity的兼容性
    【未完成】【java异常】java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy
  • 原文地址:https://www.cnblogs.com/resie/p/4500650.html
Copyright © 2011-2022 走看看