Pages

Saturday, July 18, 2015

Apache - Host a YUM Repository

There will be cases where we need to download various packages from internet. in most of these cases the YUM repository will be hosted on a web server. In this article we will see how we can Host a YUM repository on a Apache web server.

1) Create a location mkdir /var/www/html/myrepo. The location /var/www/html is the Apache Document root and this is available in Apache configuration file httpd.conf. If you are going for a new location make the necessary changes

2) Copy some of the packages to the location and run the createrepo command

[root@vx111a test]# createrepo /var/www/html/myrepo
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 0 pkgs
Spawning worker 2 with 0 pkgs
Spawning worker 3 with 0 pkgs
Spawning worker 4 with 0 pkgs
Spawning worker 5 with 0 pkgs
Spawning worker 6 with 0 pkgs
Spawning worker 7 with 0 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

Once the createrepo is done, we can see a repodata directory in the same /var/www/html/myrepo

[root@vx111a myrepo]# ll
drwxr-xr-x. 2 root root    4096 Jul 17 18:52 repodata
-rw-r--r--. 1 root root 2489408 Jul 17 18:51 zsh-5.0.2-7.el7.x86_64.rpm

3) Once the repodata is created we need to set the permissions on the location as

chmod o+r /var/www/html/myrepo -R
chcon -R httpd_sys_content_t /var/www/html/myrepo

The above last command need to execute only if Selinux is in enforcing mode

4) Once the above steps are done we need to configure the repo file for the client location in /etc/yum.repos.d/myrepo.repo as
[myrepo]
name=my custom repo
baseurl=http://apacheserver/myrepo
enabled=1
gpgcheck=0
5) We can also access the apache server where we can download the packages too.

Hope this helps, More to come

No comments :

Post a Comment