centos7.5 nginx编译安装

一、环境准备
  • wget安装
# 安装wget
sudo yum install wget
  • 安装gcc和c++
sudo yum install -y gcc gcc-c++
  • 安装perl
sudo yum install perl
二、安装nginx依赖
  • PCRE – Supports regular expressions. Required by the NGINX Core and Rewrite modules. PCRE有新旧版本,旧版本PCRE最新版本为8.43,新版本PCRE2最新版本10.33,有新特性都只会加到新版
# 查看版本:https://ftp.pcre.org/pub/pcre/
# wget https://ftp.pcre.org/pub/pcre/pcre2-10.33.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -zxf pcre-8.43.tar.gz
cd pcre-8.43
./configure
make
sudo make install
  • zlib – Supports header compression. Required by the NGINX Gzip module.
# 包获取网站http://www.zlib.net/,找到最新的安装
# wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.11.tar.gz?download
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxf zlib-1.2.11.tar.gz
./configure
make
sudo make install
  • OpenSSL – Supports the HTTPS protocol. Required by the NGINX SSL module and others.
wget http://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar -zxf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
./Configure linux-x86_64 --prefix=/usr
make
sudo make install
三、安装nginx
# 获取nginx
# 网站http://hg.nginx.org/nginx/
# 我按装的是nginx-1.15.1-RELEASE,所以获取如下:
wget http://hg.nginx.org/nginx/archive/4189160cb946.tar.gz
# 运行configure, 找到configure编译即可,文件目录可能版本不同而不一样。
./auto/configure --prefix=/usr/local/nginx --pid-path=/user/local/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-pcre=../pcre-8.00 --with-zlib=../zlib-1.2.11 --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi
# 编译
make
# 安装
sudo make install

# 部分参数说明
--prefix #nginx安装目录,默认在/usr/local/nginx
--pid-path #pid问件位置,默认在logs目录
--lock-path #lock问件位置,默认在logs目录
--with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。
--with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限
--with-http_flv_module #支持对FLV文件的拖动播放
--with-http_realip_module #支持显示真实来源IP地址
--with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩
--with-http_stub_status_module #取得一些nginx的运行状态
--with-mail #允许POP3/IMAP4/SMTP代理模块
--with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS
--with-pcre=../pcre-8.11 #注意是未安装的pcre路径
--with-zlib=../zlib-1.2.5 #注意是未安装的zlib路径
--with-debug #允许调试日志
--http-client-body-temp-path #客户端请求临时文件路径
--http-proxy-temp-path #设置http proxy临时文件路径
--http-fastcgi-temp-path #设置http fastcgi临时文件路径
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径
--http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径
参考
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值