linux下编译安装nginx完整版

0x01 nginx源码包下载:http://nginx.org/download/nginx-1.17.0.tar.gz

0x02 安装GCC与dev库

  • GCC编译器: yum install gcc gcc-c++
    正则表达式PCRE库: yum install -y pcre pcre-devel
    zlib压缩库: yum install -y zlib zlib-devel
    OpenSSL开发库: yum install -y openssl openssl-devel

0x03 安装目录及参数规划

  • nginx安装目录: /home/nginx
  • nginx配置文件目录: /home/nginx/conf/nginx.conf
  • nginx虚拟服务器配置目录: /home/nginx/vhost/
  • log日志目录: /home/nginx/log
  • pid文件目录: /home/nginx/nginx.pid
  • lock锁目录: /home/nginx/run/nginx.lock
  • 临时缓存目录: /home/nginx/cache/tmp
  • 站点目录: /home/www/wwwroot
  • nginx运行用户名: www
  • nginx运行用户组: www

 0x04 Nginx编译步骤

#创建nginx用户与用户组
groupaddd www
useradd -g www www
#解压nginx源码包并进入nginx源码根目录
[root@localhost ~]# tar -axv -f nginx-1.17.0.tar.gz && cd nginx-1.17.0

#生成makefile文件

./configure \

--prefix=/home/nginx \

--sbin-path=/home/nginx/sbin/nginx \

--conf-path=/home/nginx/conf/nginx.conf \

--error-log-path=/home/nginx/log/error.log \

--http-log-path=/home/nginx/log/access.log \

--pid-path=/home/nginx/nginx.pid \

--lock-path=/home/home/nginx.lock \

--http-client-body-temp-path=/home/nginx/client_temp \

--http-proxy-temp-path=/home/nginx/proxy_temp \

--http-fastcgi-temp-path=/home/nginx/fastcgi_temp \

--http-uwsgi-temp-path=/home/nginx/uwsgi_temp \

--http-scgi-temp-path=/home/nginx/scgi_temp \

--user=nginx \

--group=nginx \

--with-file-aio \

--with-threads \

--with-http_addition_module \

--with-http_auth_request_module \

--with-http_dav_module \

--with-http_flv_module \

--with-http_gunzip_module \

--with-http_gzip_static_module \

--with-http_mp4_module \

--with-http_random_index_module \

--with-http_realip_module \

--with-http_secure_link_module \

--with-http_slice_module \

--with-http_ssl_module \

--with-http_stub_status_module \

--with-http_sub_module \

--with-http_v2_module \

--with-mail \

--with-mail_ssl_module \

--with-stream \

--with-stream_realip_module \

--with-stream_ssl_module \

--with-stream_ssl_preread_module 
  • 正常生成无报错如下:
Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library
  • 0x05编译与安装

make && make install

0x06安装成功执行以下命令查看nginx版本号

[root@localhost nginx]# nginx -v
nginx version: nginx/1.17.0

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值