Centos7 在线源码安装Nginx

本文详细介绍了如何使用wget命令下载并解压nginx1.9.5源码到指定目录,然后通过配置和编译安装该软件。遇到的依赖问题,如HTTP rewrite和gzip模块所需的PCRE和zlib库缺失,提供了相应的解决策略,并强调了服务器防火墙对80端口的开放必要性。
  1. 使用wget命令 下载nginx 1.9.5 源码    下载到/usr/nginx 目录下

     wget  -nd -p --directory-prefix=/usr/nginx http://nginx.org/download/nginx-1.9.5.tar.gz

  2. 解压源码    到/usr/nginx 目录

    tar -zxvf   /usr/nginx/nginx-1.9.5.tar.gz -C   /usr/nginx

  3. 编译源码

    cd /usr/nginx/nginx-1.9.5 

    输入   ./configure --prefix=/usr/nginx/nginx   安装到/usr/nginx/nginx  目录

    可能报一下错误

    ./configure: error: the HTTP rewrite module requires the PCRE library.

    You can either disable the module by using --without-http_rewrite_module

    option, or install the PCRE library into the system, or build the PCRE library

    statically from the source with nginx by using --with-pcre=<path> option.

    http模块 rewrite 缺少PCRE 依赖库 

    出现以下错误

                   ./configure: error: the HTTP gzip module requires the zlib library.

                     You can either disable the module by using --without-http_gzip_module

                      option, or install the zlib library into the system, or build the zlib library

                      statically from the source with nginx by using --with-zlib=<path> option

      gzip 压缩模块  缺少 zlib 依赖库  

   清除 编译安装过程中临时文件   

        make clean   清除上次的make命令所产生的object文件(后缀为“.o”的文件)及可执行文件。 

       make distclean  类似make clean,但同时也将configure生成的文件全部删除掉,包括Makefile文件

204243_dqrh_1028135.png

4.进入   sbin 目录 启动nginx  

    ./nginx

   注意:服务器防火墙必须放开 80端口  

转载于:https://my.oschina.net/u/1028135/blog/516037

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值