源代码编译安装nginx

源代码编译安装nginx

安装前的准备

  1. 保证安装编译环境
    # yum group list
    查看是否有安装Development
    没有的话安装Development
    # yum group install "Development"
  2. wget 源代码包
    我是在官网上下载的,在http://nginx.org 中找到适合适合CentOS安装的版本。
    # wget http://nginx.org/download/nginx-1.4.7.tar.gz
  3. 解压
    # tar xf nginx-1.4.7.tar.gz
  4. 进入目录查看帮助信息并安装
    # cd nginx-1.4.7
    # ./configure --help
    # cnfigure --prefix=/usr/local/nginx

    • 报错,安装出现问题:
      ” ./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using –without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using –with-pcre= option.”
      问题是需要PCRE的共享库(library)
    • 下载,一般这个共享库的命名为:package_name-devel-xxx
      # yum install pcre-devel
      再次安装
      # ./configure --prefix=/usr/local/nginx
    • 报错,依旧是共享库的问题:
      “./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= option.”
      这次是zlib的共享库
    • 下载zlib共享库
      # yum install zlib-devel
      再次安装
      # ./configure --prefix=/usr/local/nginx
     
    Configuration summary
      \+ using system PCRE library
      \+ OpenSSL library is not used
      \+ using builtin md5 code
      \+ sha1 library is not found
      \+ using system zlib library
      nginx path prefix: "/usr/local/nginx"
      nginx binary file: "/usr/local/nginx/sbin/nginx"
      nginx configuration prefix: "/usr/local/nginx/conf"
      nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
      nginx pid file: "/usr/local/nginx/logs/nginx.pid"
      nginx error log file: "/usr/local/nginx/logs/error.log"
      nginx http access log file: "/usr/local/nginx/logs/access.log"
      nginx http client request body temporary files: "client_body_temp"
      nginx http proxy temporary files: "proxy_temp"
      nginx http fastcgi temporary files: "fastcgi_temp"
      nginx http uwsgi temporary files: "uwsgi_temp"
      nginx http scgi temporary files: "scgi_temp"
    

    显示这段信息时则表明安装成功。

  5. 开始编译
    # make
    注意,make命令必须才./configure所在的目录中执行。
  6. 安装
    # make install
  7. 启动服务
    # /usr/local/nginx/sbin/nginx
  8. 查看是否启动成功,查看80端口是否被监听。
    # netstat -ntlp

安装成功,进入网页查看:http://192.168.98.135

这里写图片描述
“Welcome to nginx!”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值