文章目录
隐藏
添加 yum 源
Nginx 不在默认的 yum 源中,可以使用 epel 或者官网的 yum 源,本例使用官网的 yum 源。
$ sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装完 yum 源之后,可以查看一下。
[root@tingfengkeji3 nginx]# yum repolist
repo id repo name
alinux3-module alinux3-module
alinux3-os alinux3-os
alinux3-plus alinux3-plus
alinux3-powertools alinux3-powertools
alinux3-updates alinux3-updates
docker-ce-stable Docker CE Stable - x86_64
epel Extra Packages for Enterprise Linux 8 - x86_64
epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64
nginx nginx repo
安装
yum install nginx
启动测试
nginx -t -c /etc/nginx/nginx.conf
可能报错
nginx: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory
安装相关依赖
yum install compat-openssl10
测试成功
nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
启动
nginx -c /etc/nginx/nginx.conf
重启
nginx -s reload -c /etc/nginx/nginx.conf