一、make编译安装
1、安装编译工具
yum install gcc pcre-devel zlib-devel openssl-devel
2、下载并解压
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
##进入nginx目录
cd nginx-1.18.0
##配置
./configure --prefix=/etc/nginx
如果要配置https可选参数–with-http_ssl_module
各种模块说明
–with-http_ssl_module
加入 ssl 模块
–with-http_image_filter_module
安装 ImageFilter 模块依赖的库
–with-http_ssi_module
在 http, server, location, if in location 等上下文中启用 ssi
–with-http_stub_status_module
输出nginx的基本状态信息
–with-http_log_module
定义日志输出格式
–with-http_gzip_module
gzip压缩
–with-http_rewrite_module
重定向
–with-http_fastcgi_module
–with-http_mp4_module --with-http_flv_module --with-pcre
视频支持
组合起来就是
./configure --prefix=/etc/nginx --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_mp4_module --with-http_flv_module --with-pcre --user=nginx --group=nginx
##make
make && make install
二、yum安装
可以指定源为阿里源或华为之类的,这里不多讲
华为下载地址
https://repo.huaweicloud.com/nginx/
yum install nginx
相关配置
firewall-cmd --query-port=80/tcp
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
设置开机启动
配置nginx开机自启动
vim /etc/rc