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.輸入以下內(nèi)容
[nginx]name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
6.執(zhí)行安裝
yum install nginx
7.查看nginx的安裝位置
whereis nginx
8.啟動和關閉nginx(如需要root權限,命令前面加sudo)
service nginx start
service nginx stop
9.查看nginx啟動狀態(tài)
service nginx status
10.修改nginx配置文件
vim /etc/nginx/conf.d/default.conf
&小記
如以上ngixn服務關閉方法無效,請閱讀下文:
使用以上命令沒有殺掉nginx進程
查看nginx進程方式:
ps -ef|grep nginx
最終使用以下命令殺掉nginx進程:
pkill -9? nginx