How to create local yum repository for linux


If your  Red Hat server is not connected official Red Hat repository also you have some concern about connecting a  global  Red Hat repository you should configure your own a local repository. I 'll explain step by step how to create local yum repository for the Red Hat server. The steps of creating a local repository are quite simple. At this post, I 'll use  HTTP to share a local repository to another machine. But there are a few ways that you can use like  FTP etc.

What you need?

  • Download  Red Hat  ISO
  • Install and  configure  Apache
  • Mount  ISO file
  • Create  repo file

Step 1:Download  ISO file

If you have  a Red  Hat  account  you can  easily get  it  from  this  link. After  download  ISO  you can  import ISO with  a cdrom also  you can  put it  under a directory on server. After  you put  iso file  under a directory  you can  mount  it  with this command  which I added below.

# ls -ld /svn/rhel-server-6.7-x86_64-dvd.iso
-rw-rw-r--. 1 ayildirim ayildirim 3841982464 Nov 5 08:50 /svn/rhel-server-6.7-x86_64-dvd.iso

# mount -o loop /svn/rhel-server-6.7-x86_64-dvd.iso /var/www/html/repo6_7
[root@redhattemplate svn]# df -h
Filesystem Size Used Avail Use% Mounted on
/svn/rhel-server-6.7-x86_64-dvd.iso 3.6G 3.6G 0 100% /var/www/html/repo6_7

Step 2:Create  a  test yum repo file 

#cat /etc/yum.repos.d/server.repo
[dvd-source]
name=RHEL 6.5 dvd repo
baseurl=file:/var/www/html/repo6_7
enabled=1
gpgcheck=0

Step 3: Check  yum repository

# yum repolist
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
dvd-source | 4.1 kB 00:00 ...
dvd-source/primary_db | 3.1 MB 00:00 ...
repo id repo name status
dvd-source RHEL 6.5 dvd repo 3,819
repolist: 3,819

Step 4:Share  this repository  for  other server

HTTP package  must  be  installed for  sharing  local repository to  other  linux  machine. Please  install  httpd  package for  Apache  entegration.

# rpm -qa|grep http
httpd-2.2.15-29.el6_4.x86_64
httpd-tools-2.2.15-29.el6_4.x86_64
[root@redhattemplate svn]# service httpd status
httpd (pid 10797) is running...

Add server  IP address to config.

# cat /etc/httpd/conf/httpd.conf |grep 80
Listen 80
ServerName <IPaddress>:80

Add this line to  httpd.conf  then restart httpd service.

#vi  /etc/httpd/conf/httpd.conf
<Directory /var/www/html/repo6_7>
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

Step 5:Use  a  web  browser to check  http connection

Check  this screenshot  how to  test repository connection  on http. As you see  the  path is  "http://IP/filename"    /var/www/html  is  default http  direction  location  . So you don't  need to add this part  to web address.

Step 6 : For the  other server  create  a  repo file and  check connectio

#vi /etc/yum.repos.d/server.repo
[repo]
name=repo
baseurl=http://IPADDRES/repo6_7
enabled=1
gpgcheck=0

Step 7: Check  repo for the client server

# yum repolist
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
repo repo 3,819
repolist: 3,819

 

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me

Related Post