search by tags

for the user

adventures into the land of the command line

setting up your own local yum repo

firstly, ensure there is somewhere to store the rpms

mkdir -p /mnt/repo

if you have shared storage to mount, you can setup a /mnt/repo mount via /etc/fstab so it’s permanent

/dev/xvdf  /mnt/repo  ext4           defaults 0      2

install apache

$ yum install httpd

enable vhosts in apache’s /etc/httpd/conf/httpd.conf by adding the following line (or uncommenting it)

NameVirtualHost *:80

add the apache virtual host that will serve /mnt/repo

$ vim /etc/httpd/conf.d/repo.conf

ServerName
ServerAdmin @
DocumentRoot "/repo"
LogFormat "%h %l %u %t \"%r\" %>s %b %D %T" repo_combined
ErrorLog "/var/log/httpd/repo-error_log"
CustomLog "/var/log/httpd/repo-access_log" repo_combined

make sure that ‘apache’ has ownership (or at least read) to /mnt/repo and any directory/file you create under it

$ chown -R apache:apache /mnt/repo/
$ chmod -R u+r /mnt/repo/

ensure that httpd is started and starts on boot

$ /sbin/service httpd start
$ /sbin/chkconfig httpd on

at this point we have a web server capable of serving files
the next thing we have to do is add files to the repository

$ cp somepackage /mnt/repo/

after placing your rpm files in /mnt/repo, create an rpm index

$ createrepo /mnt/repo/

it’s important that apache has read access to everything. if you aren’t doing the commands as apache (via sudo -u ) then fix everything up

$ chown -R apache:apache /mnt/repo/
$ chmod -R u+r /mnt/repo/

now we have a local repo that can serve rpms to our computers
to tell our localhost about our new repo

$ vim /etc/yum.repos.d/rhel-6-myrpms.repo

[rhel-6-myrpms]
name=rhel-6-myrpms
baseurl=http://myrepohostname/mnt/repo/
enabled=1
gpgcheck=0

now our repo is available on our localhost and we can install rpms that we’ve put in there

$ yum clean all
$ yum makecache
$ yum --disablerepo="*" --enablerepo="rhel-6-myrpms" install somepackage

cool