How to configure YUM with Apache server in Linux

I have written new article with the steps to configure an offline yum repository using RHEL or CentOS iso image and use the same across the network using http server and to configure yum locally without internet connection using cache

NOTE: Creating yum repository manually is not advisable if you are using Red hat. If so then you should switch to CentOS as it is a testing platform for red hat and you can get most of the RHEL features free of cost.

Firstly you need to copy all the rpms from the source DVD to your local machine.
In case of RHEL 5 the default location of package is as mentioned below

# mkdir /var/www/html/yum
# cp /dev/media/RHEL.x.x/Server/Packages/* /var/www/html/yum/

In case of RHEL 6 the default location for all the packages is as mentioned below

# mkdir /var/www/html/yum
# cp /dev/media/RHEL.x.x/Packages/* /var/www/html/yum/

So once the packages are created you need to create a repomd.xml file using createrepo but before that make sure that createrepo package is installed on your machine

# rpm -ivh /var/www/html/yum/createrepo-x.x.rpm

once the package is installed

# createrepo /var/www/html/yum/

Make an entry of the location of yum repository in yum.conf

# vi /etc/yum.conf
[Server]
name=yum
baseurl=file:///var/www/html/yum
gpgcheck=0
enabled=1
# yum clean all
# yum update

Now you can use yum to install the packages
But if you want the packages to be visible on the browser then you will need to configure apache server for the same.

# yum -y install httpd
Make the changes in hostname as per your machine
# vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin root@server.deepsoft.com
ServerName server.deepsoft.com
DocumentRoot /var/www/html/yum/
<Directory /var/www/html/yum/>
Options Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<Directory /var/www/html/yum/>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Go to the browser and type

http://localhost/yum


If you want to use the same yum repository on any other machine then specify the url of the browser in yum.conf file of that machine in the following way

# vi /etc/yum.conf
[Server]
name=yum
baseurl=http://192.168.0.100/yum
gpgcheck=0
enabled=1

I hope the article was useful.