美文网首页
CentOS 7编译安装Nginx-15(包含njs)

CentOS 7编译安装Nginx-15(包含njs)

作者: 丶那风很美 | 来源:发表于2018-07-05 22:30 被阅读0次

    假设当前目录为/nginx, 并且是使用root用户登录

    1. yum install -y wget
    2. wget http://nginx.org/download/nginx-1.15.0.tar.gz
      下载nginx源码, 这里访问的是官网, 下载速度可能很慢, 有科学上网的可以设置下代理 export http_proxy=http://127.0.0.1:8087
      用完关闭代理 export http_proxy=''
    3. yum install -y mercurial
      用来下载njs, 不用njs模块可以跳过
    4. hg clone http://hg.nginx.org/njs
      下载njs源码
    5. yum install -y gcc automake autoconf libtool make zlib zlib-devel openssl openssl-devel pcre-devel libxml2-devel.x86_64 libxslt-devel.x86_64 gd-devel.x86_64 GeoIP-devel.x86_64devel.x86_64 GeoIP-devel.x86_64
      安装依赖包
    6. yum install -y which
      njs编译需要用到
    7. tar -xzf nginx-1.15.0.tar.gz
      解压
    8. cd /nginx/nginx-1.15.0
      进入到nginx源码文件夹
    9. ./configure --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --add-module=/nginx/njs/nginx
      --add-module=/nginx/njs/nginx 是添加njs模块, 不需要的可以不加
    10. make
      编译
    11. make install
      安装
    12. cp objs/nginx /usr/sbin/
      复制nginx可执行文件到/usr/sbin/
    13. mkdir -p /var/lib/nginx/body
      创建body临时存放目录
    14. nginx
      启动nginx, 如果没有报错则表示OK

    相关文章

      网友评论

          本文标题:CentOS 7编译安装Nginx-15(包含njs)

          本文链接:https://www.haomeiwen.com/subject/bcjmuftx.html