五.(CentOS)使用阿里云鏡像包安裝nginx(不用編譯)

1.備份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

此命令將yum倉(cāng)庫(kù)文件備份

2.下載阿里云最新的倉(cāng)庫(kù)文件

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 倉(cāng)庫(kù)中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.啟動(dòng)和關(guān)閉nginx(如需要root權(quán)限,命令前面加sudo)

service nginx start

service nginx stop

9.查看nginx啟動(dòng)狀態(tài)

service nginx status

10.修改nginx配置文件

vim /etc/nginx/conf.d/default.conf

&小記

如以上ngixn服務(wù)關(guān)閉方法無(wú)效,請(qǐng)閱讀下文:

使用以上命令沒有殺掉nginx進(jìn)程

查看nginx進(jìn)程方式:

ps -ef|grep nginx

最終使用以下命令殺掉nginx進(jìn)程:

pkill -9? nginx


參考文章

更換倉(cāng)庫(kù)參考

更換倉(cāng)庫(kù)阿里云官方文檔

nginx安裝官方文檔說明

nginx安裝

nginx綜合詳細(xì)內(nèi)容

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容