Installing some RPM packages without WAN network can be painful. Why not deploy a local http yum repository to manage your rpm packages.

Assume we have two host just like this

  1. CentOS 7 Server -
  2. CentOS 7 Client -


Mount CentOS 7 DVD iso into the server .

$ mkdir -pv /media/CentOS

$ mount /dev/cd-rom /media/CentOS

Create local yum repository

# create local repository directory
$ mkdir -pv /data/mylocal

# sync rpm packages
$ cp -ap /media/CentOS/* /data/mylocal

# create local repository info
$ yum -y install createrepo --disablerepo='*' --enablerepo='c7-media'
$ createrepo /data/mylocal

Create local yum repository configuration and Test it

$ vim /etc/yum.repos.d/mylocal.repo

$ yum clean all && yum repolist all

# test the repository
$ yum search vsftp --disablerepo='*' --enablerepo=mylocal

Add a virtual host configuration in nginx.

$ yum -y install nginx

$ vim /etc/nginx/conf.d/mylocal.conf
server {
    listen 8090;
    server_name your_server_name;
    root /data/mylocal;
    location / {
    	autoindex on;  # Make Sure this line exist !

$ sudo nginx -t 
$ systemctl reload nginx
$ systemctl enable nginx

Consider the only repository is mylocal , you can delete other *.repo saved in /etc/yum.repos.d , which make mylocal as the default repository.

Allow the port you defined in nginx virtual host through iptables.

# port 8090 defined in nginx 
$ iptable -I INPUT -m state --state NEW -p tcp --dport 8090 -j ACCEPT 

Remember to umount the DVD iso .

$ umount /media/CentOS


Add a new repository configuration saved in /etc/yum.repos.d/mylocal .

$ vim /etc/yum.repos.d/mylocal.repo

Set mylocal as default repository and update yum cache.

$ mv CentOS-*.repo /tmp

$ yum clean all && yum makecache

Try to install a rpm package whether the repository run correctly or not.

$ yum install w3m -y

Update Repository

You need to update repository manually, when you want to add some new packages.

Assume you want to add package vsftpd . The package dependence could be solved by yum command.

# execute these command in a centos contain WAN network

# clear cache packages
$ find /var/cache/yum/x86_64/7 -name "*.rpm" -exec rm -f {} \;

# download vsftpd package
$ yum install vsftpd
	Resolving Dependencies                                                 
	--> Running transaction check                                           
	---> Package vsftpd.x86_64 0:3.0.2-25.el7 will be installed             
	--> Finished Dependency Resolution                                                                                                   
	Dependencies Resolved                    
	 Package         Arch         Version      Repository       Size 
	 vsftpd          x86_64        3.0.2-25.el7       base         171 k 
	Transaction Summary        
	Install  1 Package     
	Total download size: 171 k     
	Installed size: 353 k     
	Is this ok [y/d/N]: d   # Choose d !!!  
	Background downloading packages, then exiting:  
	vsftpd-3.0.2-25.el7.x86_64.rpm               | 171 kB  00:00:06 
	exiting because "Download Only" specified 
# tar all of the related packages 
$ mkdir -pv /tmp/vsfptd
$ find /var/cache/yum/x86_64/7 -name "*.rpm" -exec cp {} /tmp/vsftpd \;
$ cd /tmp/vsftpd && tar -jcf vsftpd_rpms.tar.bz2 *.rpm

Upload the vsftpd_rpms.tar.bz2 to server , which means the, then create repository once again.

# assume vsftpd_rpms.tar.bz2 saved in /usr/local/src

$ tar -xf /usr/local/src/vsftpd_rpms.tar.bz2 -C /data/mylocal/Packages
$ createrepo /data/mylocal

BOOM ! Well Done ! You do a great job.