Build a Centos 7 Repo Rumi, August 2, 2020 Install httpd [root@www ~]# yum -y install httpd # remove welcome page [root@www ~]# rm -f /etc/httpd/conf.d/welcome.conf Configure httpd. Replace server name to your own environment. [root@www ~]# vi /etc/httpd/conf/httpd.conf # line 86: change to admin's email address ServerAdmin root@srv.world # line 95: change to your server's name ServerName www.srv.world:80 # line 151: change AllowOverride All # line 164: add file name that it can access only with directory's name DirectoryIndex index.html index.cgi index.php # add follows to the end # server's response header ServerTokens Prod # keepalive is ON KeepAlive On [root@www ~]# systemctl start httpd [root@www ~]# systemctl enable httpd Install other required packages. [root@dlp ~]# yum -y install rsync createrepo Create directories for repository and copy data from CentOS official Repository. Create directories [root@dlp ~]# mkdir -p /var/www/repos/centos/7/{os,updates,extras}/x86_64 [root@dlp ~]# chmod -R 755 /var/www/repos Copy from official repo [root@dlp ~]# rsync -avz --delete --exclude='repodata' \ rsync://ftp.riken.jp/centos/7/os/x86_64/ \ /var/www/repos/centos/7/os/x86_64/ [root@dlp ~]# rsync -avz --delete --exclude='repodata' \ rsync://ftp.riken.jp/centos/7/updates/x86_64/ \ /var/www/repos/centos/7/updates/x86_64/ [root@dlp ~]# rsync -avz --delete --exclude='repodata' \ rsync://ftp.riken.jp/centos/7/extras/x86_64/ \ /var/www/repos/centos/7/extras/x86_64/ Create metadata repositories [root@dlp ~]# createrepo /var/www/repos/centos/7/os/x86_64/ [root@dlp ~]# createrepo /var/www/repos/centos/7/updates/x86_64/ [root@dlp ~]# createrepo /var/www/repos/centos/7/extras/x86_64/ Add copy task to daily jobs. [root@dlp ~]# vi /etc/cron.daily/update-repo # create new #!/bin/bash VER='7' ARCH='x86_64' REPOS=(os updates extras) for REPO in ${REPOS[@]} do rsync -avz --delete --exclude='repodata' \ rsync://ftp.riken.jp/centos/${VER}/${REPO}/${ARCH}/ /var/www/repos/centos/${VER}/${REPO}/${ARCH}/ createrepo /var/www/repos/centos/${VER}/${REPO}/${ARCH}/ done [root@dlp ~]# chmod 755 /etc/cron.daily/update-repo Configure Apache httpd to provide repository for other Client Servers. [root@dlp ~]# vi /etc/httpd/conf.d/repos.conf # create new Alias /repos /var/www/repos <directory /var/www/repos> Options +Indexes Require all granted </directory> [root@dlp ~]# systemctl restart httpd If Firewalld is running, allow HTTP service. [root@dlp ~]# firewall-cmd --add-service=http --permanent success [root@dlp ~]# firewall-cmd --reload success On Client Servers, Change settings of Yum to refer to Local Yum Mirror. It’s OK all. [root@client ~]# vi /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=http://centos.bintel.com.bd/repos/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra baseurl=http://centos.bintel.com.bd/repos/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra baseurl=http://centos.bintel.com.bd/repos/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Administrations Configurations (Linux) CentOSCentOS 7Repo