阿里雲伺服器yum源出錯和更新等問題

2021-06-26 11:28:55 字數 1871 閱讀 4676

新建乙個指令碼,並執行,帖下官方**

這個指令碼跑起來會有錯誤,問題在紅色字型部分,被grep的兩個檔案可能沒有 「red hat enterprise linux server release」這樣的字眼,可手動改/etc/issue等檔案(增加這行文字),使得變數os_release和os_release_2為真,增加的這一行要放在有作業系統版本號的那一行

#!/bin/bash

#########################################

#function:    update yum source

#usage:       bash update_yum_source.sh

#author:      customer service department

#company:     alibaba cloud computing

#version:     2.1

#########################################

check_os_release()

modify_rhel5_yum()

modify_rhel6_yum()

##########start######################

#check lock file ,one time only let the script run one time 

lockfile=/tmp/.$(basename $0)

if [ -f "$lockfile" ]

then

echo -e "\033[1;40;31mthe script is already exist,please next time to run this script.\n\033[0m"

exit

else

echo -e "\033[40;32mstep 1.no lock file,begin to create lock file and continue.\n\033[40;37m"

touch $lockfile

fi#check user

if [ $(id -u) != "0" ]

then

echo -e "\033[1;40;31merror: you must be root to run this script, please use root to install this script.\n\033[0m"

rm -rf $lockfile

exit 1

fios_type=$(check_os_release)

if [ "x$os_type" == "x" ]

then

echo -e "\033[1;40;31mos type is not redhat or centos,so this script is not executede.\n\033[0m"

rm -rf $lockfile

exit 0

else

echo -e "\033[40;32mthis os is $os_type.\033[40;37m"

echo "$os_type" |grep 5 >/dev/null

if [ $? -eq 0 ]

then

modify_rhel5_yum

rm -rf $lockfile

exit 0

fiecho "$os_type"|grep 6 >/dev/null

if [ $? -eq 0 ]

then

modify_rhel6_yum

rm -rf $lockfile

exit 0

fifi

rm -rf $lockfile

阿里雲伺服器Centos系統的yum源配置

最近在玩阿里雲伺服器,本身預設自帶的yum源的php版本只有5.1,而wordpress最低要求是5.3。一開始沒有意識到時源的問題,試了好久沒搞懂,我的linux建站水平是真菜啊.這兩天意識到了問題了,現在把解救方法貼出來 1,進入yum源配置目錄 cd etc yum.repos.d 3,更新玩...

本地yum源和阿里雲網路yum源的搭建

一 搭建本地yum源 1 刪掉原檔案 rm fr etc yum.repos.d 2 配置檔案 vi etc yum.repos.d centos7.repo 3 清空快取,生成列表 yum clean all 清空yum快取 yum repolist 生成快取列表 二 搭建aliyum網路yum源...

阿里雲伺服器

ssh 使用者名稱 ip位址以下操作都在遠端伺服器上進行操作 ubuntu 16.04 sudo apt get updateapt get install mysql server apt get install libmysqlclient devsudo apt get install red...