@startuml
start
:查看环境;
:检查网络连接;
if (网络可用?) then (yes)
:添加 Yum 源;
:安装 Nginx;
:配置服务;
:设置防火墙;
:查看网页;
if (网页显示成功?) then (yes)
:显示 "Welcome to nginx!";
else (no)
:检查配置或网络;
endif
else (no)
:检查网络连接问题;
endif
stop
@enduml
前言
我在下载 Nginx 的时候出现报错
:No package nginx available.
按照网上配置阿里云的教程还有或有错误
[root@192 ~]# yum install nginx -y Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com No package nginx available. Error: Nothing
经过反复试错后找到此方法
步骤
查看环境
本人环境
cat /etc/redhat-release
查看网络环境
先检查服务器是否可以连接外网,用百度来举例,若出现一下结果,说明可以连接,可以手动暂停CTRL + c
ping www.baidu.com

添加 yum源
如果直接使用 yum install nginx -y,会出现Not Found的情况,所以我们使用 epel 或者官网的 yum源,本例使用官网的源
sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装完成后,可以查看一下
sudo yum repolist

安装 Nginx
使用命令
sudo yum install nginx
配置 Nginx服务
设置开机启动
sudo systemctl enable nginx
启动服务
sudo systemctl start nginx
停止服务
sudo systemctl start nginx
重新加载,重启服务
sudo systemctl reload nginx
启动后查看服务进程
ps -ef | grep 'nginx'

