Create internal repository server on CentOS 7

This post shows how to create copy of CentOS 7 repositories:

  • base
  • centosplus
  • extras
  • updates
  • epel

And configure internal repository server.

Disable SELINUX and Firewall

systemctl disable firewalld
systemctl stop firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

Add EPEL repository in addition to default repositories:

yum -y install epel-release

Update epel.repo file. Because reposync can fail:

# vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
enabled=1
gpgcheck=0

Install packages:

yum -y install createrepo
yum -y install yum-utils
yum -y install httpd
systemctl enable httpd

Create directory for repositories:

mkdir -p /data/repos201602

Sync repositories:

reposync --gpgcheck -l --repoid=base       --download_path=/data/repos201602/ --downloadcomps --download-metadata
reposync --gpgcheck -l --repoid=centosplus --download_path=/data/repos201602/ --downloadcomps --download-metadata
reposync --gpgcheck -l --repoid=extras     --download_path=/data/repos201602/ --downloadcomps --download-metadata
reposync --gpgcheck -l --repoid=updates    --download_path=/data/repos201602/ --downloadcomps --download-metadata
reposync            -l --repoid=epel       --download_path=/data/repos201602/ --downloadcomps --download-metadata

Create new repositories:

createrepo /data/repos201602/base/ -g comps.xml
createrepo /data/repos201602/centosplus/
createrepo /data/repos201602/extras/
createrepo /data/repos201602/updates/
createrepo /data/repos201602/epel/ -g comps.xml

Remove all files from /etc/yum.repos.d/

mv /etc/yum.repos.d/* /root/

Create new file /etc/yum.repos.d/internal-repos.repo

# vi /etc/yum.repos.d/internal-repos.repo
[base]
name=CentOS Base
baseurl=http://192.168.0.1/repos/base/
gpgcheck=0
enabled=1

[updates]
name=CentOS Updates
baseurl=http://192.168.0.1/repos/updates/
gpgcheck=0
enabled=1

[extras]
name=CentOS Extras
baseurl=http://192.168.0.1/repos/extras/
gpgcheck=0
enabled=1

[centosplus]
name=CentOS CentOSPlus
baseurl=http://192.168.0.1/repos/centosplus/
gpgcheck=0
enabled=1

[epel]
name=Extra Packages for Enterprise Linux 7
baseurl=http://192.168.0.1/repos/epel/
gpgcheck=0
enabled=1

Create new HTTPD configuration file:

# vi /etc/httpd/conf.d/repos.conf
Alias /repos /data/repos201602
<Directory /data/repos201602>
    Options Indexes FollowSymLinks
    Require all granted
</Directory>

Start HTTPD service:

systemctl start httpd

Check:

# yum clean all
# yum repolist
repo id            repo name                                     status
base               CentOS Base                                   9 007
centosplus         CentOS CentOSPlus                                43
epel               Extra Packages for Enterprise Linux 7         9 422
extras             CentOS Extras                                   191
updates            CentOS Updates                                  825

Install some packages or group packages:

yum -y groupinstall "X Window system" "MATE Desktop"

Leave a Reply

Your email address will not be published. Required fields are marked *