CentOS 基础源配置大全

juns_6969 2026-5-30 23 5/30

Centos 基础源

cat > /etc/yum.repos.d/Centos.repo << EOF
[Base]
name=base yum
baseurl=https://mirrors.aliyun.com/centos/7/os/x86_64/
enabled=1
gpgcheck=0

[Updates]
name=updates
baseurl=https://mirrors.aliyun.com/centos/7/updates/x86_64/
enabled=1
gpgcheck=0

[Extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/7/extras/x86_64/
enabled=1
gpgcheck=0
EOF

EPEL 源

cat > /etc/yum.repos.d/Epel.repo << EOF
[Epel]
name=epel yum
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/
enabled=1
gpgcheck=0
EOF

Nginx 源

cat > /etc/yum.repos.d/nginx.repo << 'EOF'
[nginx-stable]
name=nginx stable repo
baseurl=https://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=https://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF

MySQL 源

cat > /etc/yum.repos.d/Mysql.repo << EOF
[Mysql]
name=mysql 5.7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/
enabled=1
gpgcheck=0
EOF

Sclo RH 源

cat > /etc/yum.repos.d/Sclo.repo << EOF
[Sclo-rh]
name=sclo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh
enabled=1
gpgcheck=0
EOF

Zabbix 源

cat > /etc/yum.repos.d/Zabbix.repo << EOF
[Zabbix]
name=Zabbix 5.0
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/
enabled=1
gpgcheck=0

[Zabbix-Frontend]
name=zabbix-frontend
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/
enabled=1
gpgcheck=0
EOF

PHP 源(Remi)

cat > /etc/yum.repos.d/remi.repo << 'EOF'
[remi]
name=Remi RPM repository for Enterprise Linux 7
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/remi/$basearch/
enabled=1
gpgcheck=0

[remi-php72]
name=Remi PHP 7.2 repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php72/$basearch/
enabled=1
gpgcheck=0

[remi-php74]
name=Remi PHP 7.4 repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php74/$basearch/
enabled=0
gpgcheck=0

[remi-php80]
name=Remi PHP 8.0 repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/7/php80/$basearch/
enabled=0
gpgcheck=0
EOF

GitLab 源

cat > /etc/yum.repos.d/gitlab.repo << EOF
[gitlab]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
enabled=1
gpgcheck=0
EOF

Jenkins 源

cat > /etc/yum.repos.d/jenkins.repo << 'EOF'
[jenkins]
name=Jenkins-stable
enabled=1
type=rpm-md
baseurl=https://pkg.jenkins.io/redhat-stable
gpgkey=https://pkg.jenkins.io/redhat-stable/repodata/repomd.xml.key
gpgcheck=1
EOF

Maven 仓库镜像

编辑 /usr/local/maven/conf/settings.xml,在 <mirrors> 节点中添加:

<mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
</mirror>

Docker CE 源

cat > /etc/yum.repos.d/docker-ce.repo << 'EOF'
[docker-ce]
name=docker-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/7.9/x86_64/stable/
enabled=1
gpgcheck=0
EOF

以上汇总了 CentOS 7 环境下常用的 YUM 软件源配置。所有源均使用国内镜像(阿里云 / 清华 TUNA)加速下载,适用于无法直接访问官方源的内网或国内服务器环境。

- THE END -

juns_6969

5月30日13:48

最后修改:2026年5月30日
2

非特殊说明,本博所有文章均为博主原创。

共有 1 条评论

  1. juns_6969博主

    🤧