Introduction

In this article we are going to learn How to configure Local Yum Repository Package Installer using Apache Server. Previously in one of my article I already explained How to configure Yum Repository Package Manager using FTP Server

Download Free Linux eBook HERE! "Learn Linux in 5 Days" - A Free Linux eBooks for Beginners

Yum Repository Package installer is used to install packages by downloading directly from repository server. almost each and every package in Linux want some dependencies (Supportable Packages/Addon) to work.When we install some packages in Linux system it asks for dependencies. The main Advantage of Yum repository package installer is when you ask for install some package (for ex : yum -y install httpd) it will automatically download the requested package with all required dependencies for that package and install it. You can use yum to Install, Upgrade, Remove the Package’s.

Follow the below steps to Configure Local Yum Repository Package Installer using Apache Server

Step : 1 Install Required Pachages

First you have to install required packages to configure yum repository package installer. So we need to install httpd (Apache Server Package), yum packages and createrepo with its dependencies.

Here I am installing httpd apache server package.

Note : Here we are configuring Local Yum Repository Package Installer and I am installing required packages for that using global official yum repository server. So don’t get confused.

[root@localhost ~]# yum -y install httpd # Install apache server Package Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.viethosting.com * extras: mirror.vbctv.in * updates: mirror.vbctv.in Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-59.el6.centos will be installed --> Processing Dependency: httpd-tools = 2.2.15-59.el6.centos for package: httpd-2.2.15-59.el6.centos.x86_64 --> Running transaction check ---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be updated ---> Package httpd-tools.x86_64 0:2.2.15-59.el6.centos will be an update --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================= Package Arch Version Repository Size ========================================================================================================= Installing: httpd x86_64 2.2.15-59.el6.centos base 834 k Updating for dependencies: httpd-tools x86_64 2.2.15-59.el6.centos base 79 k Transaction Summary ========================================================================================================= Install 1 Package(s) Upgrade 1 Package(s) Total download size: 913 k Downloading Packages: (1/2): httpd-2.2.15-59.el6.centos.x86_64.rpm | 834 kB 00:03 (2/2): httpd-tools-2.2.15-59.el6.centos.x86_64.rpm | 79 kB 00:00 --------------------------------------------------------------------------------------------------------- Total 210 kB/s | 913 kB 00:04 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Updating : httpd-tools-2.2.15-59.el6.centos.x86_64 1/3 Installing : httpd-2.2.15-59.el6.centos.x86_64 2/3 Cleanup : httpd-tools-2.2.15-29.el6.centos.x86_64 3/3 Verifying : httpd-tools-2.2.15-59.el6.centos.x86_64 1/3 Verifying : httpd-2.2.15-59.el6.centos.x86_64 2/3 Verifying : httpd-tools-2.2.15-29.el6.centos.x86_64 3/3 Installed: httpd.x86_64 0:2.2.15-59.el6.centos Dependency Updated: httpd-tools.x86_64 0:2.2.15-59.el6.centos Complete!

Then install required packages of yum repository package installer and createrepo.

[root@localhost packages]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm Preparing... ########################################### [100%] 1:yum ########################################### [100%] [root@localhost packages]# rpm -ivh yum-utils-1.1.30-37.el6.noarch.rpm Preparing... ########################################### [100%] 1:yum-utils ########################################### [100%] [root@localhost pub]# rpm -ivh createrepo-0.9.9-24.el6.noarch.rpm Preparing... ########################################### [100%] 1:createrepo ########################################### [100%]

To confirm the installed package you can refer the below command.

[root@localhost ~]# rpm -qa | grep httpd # Confirm the Installed httpd package httpd-tools-2.2.15-59.el6.centos.x86_64 httpd-2.2.15-59.el6.centos.x86_64

To confirm the installed packages of yum refer the below command.

[root@localhost ~]# rpm -qa | grep yum yum-3.2.29-40.el6.centos.noarch yum-metadata-parser-1.1.2-16.el6.x86_64 yum-plugin-security-1.1.30-14.el6.noarch PackageKit-yum-plugin-0.5.8-21.el6.x86_64 yum-utils-1.1.30-14.el6.noarch yum-plugin-fastestmirror-1.1.30-14.el6.noarch PackageKit-yum-0.5.8-21.el6.x86_64

confirm createrepo package is installed or not using below command.

[root@localhost ~]# rpm -qa | grep createrepo createrepo-0.9.9-26.el6.noarch

Start the Apache Server service.

[root@localhost ~]# /etc/init.d/httpd start # Start the Apache Server Service Starting httpd: [ OK ]

Access the default page of apache server by using URL http://localhost to confirm if its properly working.

Start the Apache Service on Startup.

[root@localhost ~]# chkconfig --level 35 httpd on # Start the Apache Server service on Startup [root@localhost ~]# chkconfig --list httpd httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off

Step : 2 Copy All Packages from Linux Installation OS Media

The main document directory of apache server is /var/www/html. So here we are going to create a directory named “yumrepo” to keep all our repositories. So first create a directory.

[root@localhost ~]# mkdir /var/www/html/yumrepo

Give appropriate permission’s. Here I am giving full permission.

[root@localhost ~]# chmod -R 777 /var/www/html/yumrepo/

Then insert you Linux Installation DVD in DVD-ROM and mount it to some directory.

[root@localhost ~]# mount /dev/cdrom /media

If you have iso image of the OS then you can refer the below command to mount the iso image.

[root@localhost ~]# mount -t iso9660 -o loop CentOS-6.5-x86_64-bin-DVD1.iso /mnt/hgfs

I have iso image of the OS and I mounted the iso image to /mnt/hgfs directory. So after mount the OS media go in to the packages directory which is contains all the packages of operating system and copy all the packages to /var/www/html/yumrepo directory. Refer the below command.

[root@localhost ~]# cp /mnt/hgfs/CentOS-6.5-x86_64-bin-DVD1/Packages/* -rfv /var/www/html/yumrepo/

Restart the Apache Server service to take changes effect.

[root@localhost ~]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]

After copy all packages from OS DVD access the yumrepo directory by using apache server using URL http://192.168.0.104/yumrepo

Also Read :

Step : 3 Create “.repo” file for Yum Repository Package Installer

The main configuration file of yum repository package installer is /etc/yum.conf. I have shown my yum.conf file below. Here you can see that we have to put our .repo file in /etc/yum.repos.d directory. “.repo” file is used to mention our package location path.

[root@localhost ~]# cat /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release # This is the default, if you make this bigger yum won't see if the metadata # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. # It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d

/etc/yum.repos.d directory is already contains some “.repo” files which is configured with global official yum repository details. So to configure our own local yum repository package installer server we have to move default “repo” files from /etc/yum.repos.d.

Here I moving to all “repo” files to /test directory.

[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo [root@localhost yum.repos.d]# mv *.repo /test/

after move all the “.repo” files just create a new “.repo” file. Here I am creating a “.repo” file named “file.repo”

[root@localhost yum.repos.d]# touch file.repo

After create a “.repo” file just edit that file and enter the below details.

Note : Here I entered my server’s IP Address and package directory location details. you have to enter you one.

[root@localhost yum.repos.d]# nano file.repo [base] name=base baseurl=http://192.168.0.104/yumrepo/ enabled=1 gpgcheck=0

Step : 4 Create Database file for Yum Repository

After create the “repo” file we have to create database file for yum repository package installer. The database file is a XML file which contains all package details and server details. So to create yum repository database file you can use createrepo command.

Syntax : createrepo [path of package location]

Here our Package Location is /var/www/html/yumrepo so the command would something like as shown below.

[root@localhost ~]# createrepo /var/www/html/yumrepo/ Spawning worker 0 with 3995 pkgs Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete

Restart the Apache Server service to take changes effect.

[root@localhost ~]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]

Stop the Firewall.

[root@localhost ~]# /etc/init.d/iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ]

You can use yum list command to list all available packages in yum repository.

[root@localhost ~]# yum list

OR if you are looking for some particular package then you can search using grep command. refer the command below.

[root@localhost ~]# yum list | grep vsftpd vsftpd.x86_64 2.2.2-11.el6_4.1 @base

We are done with required configuration of Local YUM Repository Package Installer from Server Side. Let’s look toward client side configurations.

Step : 5 Configure YUM Repository Package Installer from Client Side

Install Required Packages

Install requires packages of yum.

[root@localhost packages]# rpm -ivh yum-3.2.29-73.el6.centos.noarch.rpm Preparing... ########################################### [100%] 1:yum ########################################### [100%] [root@localhost packages]# rpm -ivh yum-utils-1.1.30-37.el6.noarch.rpm Preparing... ########################################### [100%] 1:yum-utils ########################################### [100%]

Create a “.repo” file

Then the next step is we have to create a “.repo” file by following same steps like we created a “.repo” file during server configuration on Step : 3 above.

After create a .repo file just edit it and copy below lines and then save the file.

[root@localhost yum.repos.d]# nano file.repo [base] name=base baseurl=http://192.168.0.104/yumrepo enabled=1 gpgcheck=0

Note : The above “.repo” file configurations are same we did during yum repository package installer server configuration. Refer Step 3 above.

Now we are done with YUM Repository client configuration. Now just use yum command to install a package.

[root@localhost ~]# yum -y install dhcp Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package dhcp.x86_64 12:4.1.1-51.P1.el6.centos will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: dhcp x86_64 12:4.1.1-51.P1.el6.centos base 823 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 823 k Installed size: 1.9 M Downloading Packages: dhcp-4.1.1-51.P1.el6.centos.x86_64.rpm | 823 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64 1/1 Verifying : 12:dhcp-4.1.1-51.P1.el6.centos.x86_64 1/1 Installed: dhcp.x86_64 12:4.1.1-51.P1.el6.centos Complete!

This is How we can configure Local Yum Repository Package Installer using Apache Server. If you found this article useful then Like Us, Share Us, Subscribe our Newsletter OR if you have something to say then feel free to comment on the comment box below.