How to Create Local Yum Repository Server on CentOS 7

Create Local Yum Repository Server on CentOS 7

Here you will understand that how to create a local YUM repository server on CentOS 7. By the use of local YUM repository server, client machines can install the require rpm packages easily without internet access. Yum stands for Yellow dog updater modified, actually Yum is a local repository for RPM Packages. By use of Yum, dependencies of any packages is automatically install. Yum is a tool for the use of installing, upgrading, querying, managing and getting rpm software packages of Red Hat, CentOS, Oracle Enterprise Linux and etc.

Configuration of Server Machine:

Give a suitable name for local Yum repository server, here we have given the server name "repository-server". To check the name of server inside file "hostname" in directory "/etc", type the following command.

cat /etc/hostname

how to create local yum repository on centos

To check the IP configuration of CentOS Linux local YUM Repository Server, type the below mention command. This command is also works on Red Hat Enterprise Linux, Oracle Enterprise Linux and etc.

cat /etc/sysconfig/network-scripts/ifcfg-ens33

how to create local yum repository on centos

In CentOS linux, directory "media" is used to mount the cdrom device. To check directory "media" that is always available in root "/", type the following command.

ls /

how to create local yum repository on centos

To check the cdrom is available in directory "/dev", type the following command.

ls /dev

how to create local yum repository on centos

Mount the device "cdrom" to directory "media", type the following command.

mount /dev/cdrom /media/

how to create local yum repository on centos

To check the cdrom device "/dev/sr0" is successfully mount to directory "/media", type the following command.

df -hT


how to create local yum repository on centos

To check cdrom data has successfully mounted, first use command "cd" to enter in the directory "media" then use command "ls" to list cdrom data .

cd /media/
ls

how to create local yum repository on centos

To check the available yum repository files in directory "/etc/yum.repos.d/", type the below mention commands.

cd /etc/yum.repos.d/
ll

how to create local yum repository on centos

Create a local repository file, there is no such requirement of local repository file in server but it can be use when internet is not available. To create a local repository file in server, type the below mention command.

vi repository-server.repo

how to create local yum repository server on centos 7

Note: you can create repository file with any suitable name, In the above image you can see that we have created repository file "repository-server.repo".

Add the below lines in repository file "repository-server.repo".

[Packages]
Name = Repository-Server
baseurl = file:///media/
enabled = 1
gpgcheck = 0

how to create local yum repository server on centos 7

Here,
Packages --> Repository ID.
Repository-Server --> Repository Name.
enabled = 1 --> Repository is enable.
enabled = 0 --> Repository is disable.
gpgcheck = 0 --> Signature Verification is set to disable.

After create the new repository file, type the below mention command.

yum clean all

how to create local yum repository server on centos 7

To list all of the repositories, type the below mention command.

yum repolist

how to create local yum repository server on centos 7

Now install the below mention packages that will be used to connect client machines with centralized repository server.
  • ftp
  • vsftpd
To install the package "ftp", type the below mention command.

yum install ftp

how to install ftp server on centos 7

In the above image you can see that the repository "Packages" has used for the installation of Package "FTP".Allow Service "ftp" in firewall. To allow Service "ftp" in firewall "firewalld", type the below mention command.

firewall-cmd --permanent --add-service=ftp

how to install and configure ftp server on centos 7

After add the service of "FTP" in Firewall "firewalld", reload Firewall "firewalld". To reload Firewall "firewalld", type the following command.

firewall-cmd --reload

how to install and configure ftp server on centos 7

For security, performance and stability of FTP server install Package "vsftpd" that is FTP Server daemon. To install Package "vsftpd", type the following command.

yum install vsftpd

how to install and configure ftp server on centos 7

In the above image you can see that repository "base" is being used for the installation of Package "vsftpd", because Package "vsftpd" is not available in Repository "Packages" 

The Package "vsftpd" has been successfully installed.

how to install and configure ftp server on centos 7

To start the service of "vsftpd", type the following command.

systemctl start vsftpd

how to install and configure ftp server on centos 7

To enable the service of "vsftpd", type the following command.

systemctl enable vsftpd

how to install and configure ftp server on centos 7

To check the status of FTP daemon "vsftpd", type the following command.

how to install and configure ftp server on centos 7

Now it is a time to create a repository directory in directory "FTP" for Linux client machine. To enter in directory "FTP", type the following command.

cd /var/ftp

how to configure ftp server on centos 7

Create directory "centos7" in directory "ftp" by use of mkdir command.

mkdir centos7

how to configure ftp server on centos 7

Now copy all the data of cdrom directory "media" to the directory "centos7".

cp -rf /media/* /var/ftp/centos7/

how to install and configure ftp server on centos 7

To check all the data with size in directory "centos7", type the following command.

ll -alhrt /var/ftp/centos7/

ftp server on centos 7

Configuration of Client Machine:

To check the name of client machine inside file "hostname" in directory "/etc", type the below mention command.

cat /etc/hostname

how to mount local yum repository on centos client machine

To check the IP configuration of CentOS Linux client machine, type the below mention command. This command is also works on Red Hat Enterprise Linux, Oracle Enterprise Linux and etc.

cat /etc/sysconfig/network-scripts/ifcfg-ens33

how to mount local yum repository on centos client machine

Edit the file "hosts" for add the server and client machine entries "IP with Name", type the following command for edit the file. 

vi /etc/hosts

how to mount local yum repository on centos client machine

Add the following lines that is client machine and server machine "IP with Name".

192.168.10.221 apache
192.168.10.219 repository-server

how to mount local yum repository on centos client machine

To check the repository file that already available in client machine repository directory "/etc/yum.repos.d/", type the following command.

cd /etc/yum.repos.d/
ls

repository

Now remove all the repository files that available in repository directory "/etc/yum.repos.d/", type the following command.

rm -fv *.repo

repository

Create a new repository file "centos7.repo" in yum repository directory "/etc/yum.repos.d/", type the following command.

vi centos7.repo

repository

Add the below lines in repository file "centos7.repo".

[Packages]
Name = Repository For Client
baseurl = ftp://repository-server/centos7/
enabled = 1
gpgcheck = 0

repository

To check the repository list in Linux client machine, type the following command.

yum repolist

repository

To install the Apache Package "httpd", type the following command.

yum install httpd

how to install apache server on centos 7

The Apache web server in Linux client machine "Apache" has been successfully installed.

how to install apache server on centos 7

Thanks for Read this Article

Comments