centos8源码安装nginx

本文详细介绍了如何检查和安装Nginx的必要依赖(如gcc、openssl、zlib和pcre),包括使用yum工具和手动编译源码包的过程,以及常用的运维命令和Nginx模块配置选项。
摘要由CSDN通过智能技术生成

一、 检查nginx依赖,这些依赖有些也是安装其他软件所需的编译依赖
检查gcc编译器

rpm -qa|grep gcc

ssl功能需要openssl库

rpm -qa|grep openssl

gzip模块需要zlib库

rpm -qa|grep zlib

rewrite模块需要pcre库

rpm -qa|grep pcre

若没有直接通过yum安装

yum install -y gcc
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

二、下载nginx源码包
1、nginx官网下载源码包。
2、我网盘下载 提取码:1cxz
3、拷到服务器上放在喜欢的位置,解压

tar -zxvf nginx-1.24.0.tar.gz

三、编译
进入解压后的nginx文件夹

./configure --with-http_stub_status_module --with-http_ssl_module
make
make install

nginx默认安装在 /usr/local/nginx
四、运维命令

/usr/local/nginx/sbin/nginx  # 启动
/usr/local/nginx/sbin/nginx -s stop  # 快速停止
/usr/local/nginx/sbin/nginx -s quit  # 完整有序的停止
/usr/local/nginx/sbin/nginx -s reload # 重新加载
强制停止:
ps -ef | grep nginx
kill -9 [进程号]
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf  # 指定配置文件

附:nginx模块
–with-compat
–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
–with-cc-opt=‘-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC’
–with-ld-opt=‘-Wl,-z,relro -Wl,-z,now -pie’

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值