1、下载rpm包:
代码语言:shell复制wget http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.18.0-1.el8.ngx.x86_64.rpm
2、执行升级命令:
代码语言:shell复制rpm -Uvh nginx-1.18.0-1.el8.ngx.x86_64.rpm
2.1 安装命令:
代码语言:shell复制先执行
rpm -ivh nginx-1.18.0-1.el8.ngx.x86_64.rpm
再执行
yum install nginx
3、查看版本:
代码语言:css复制nginx -v
或者
rpm -qa|grep nginx
4、其他:
如果无法启动服务。查看日志/var/log/nginx/error.log
1、提示版本问题;
代码语言:c#复制[emerg] 247912#247912: module "/usr/lib64/nginx/modules/ngx_http_image_filter_module.so" version 1014001 instead of 1018000 in /usr/share/nginx/modules/mod-http-image-filter.conf:1
解决办法:
代码语言:css复制yum remove nginx-mod*;
yum install nginx-moudle-*
/usr/sbin/nginx -t;
/usr/sbin/nginx -s reload;
如果nginx源不正确,使用下面方法设置
centos8配置nginx源:
执行命令:
代码语言:c复制vim /etc/yum.repos.d/nginx.repo
复制以下内容,保存:
代码语言:shell复制[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
首次安装时,可以先设置源:
然后执行以下命令:
代码语言:c复制yum install nginx
systemctl enable nginx
开启nginx:systemctl start nginx
停止nginx:systemctl stop nginx
重启nginx:systemctl reload nginx