1.备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
此命令将yum仓库文件备份
2.下载阿里云最新的仓库文件
switch(OS-Version)
case when CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-5.repo
break;
case when CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo
break;
case when CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo
break;
default
beak;
3.生成缓存
yum makecache
4.添加或修改 yum 仓库中nginx配置
vim /etc/yum.repos.d/nginx.repo
5.输入以下内容
[nginx]name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
6.执行安装
yum install nginx
7.查看nginx的安装位置
whereis nginx
8.启动和关闭nginx(如需要root权限,命令前面加sudo)
service nginx start
service nginx stop
9.查看nginx启动状态
service nginx status
10.修改nginx配置文件
vim /etc/nginx/conf.d/default.conf
&小记
如以上ngixn服务关闭方法无效,请阅读下文:
查看nginx进程方式:
ps -ef|grep nginx
最终使用以下命令杀掉nginx进程:
pkill -9 nginx