How to Create Local Yum Repo on CentOS 7

preview_player
Показать описание
Step 1: Configure Network Access

yum install httpd

Step 2: Create Yum Local Repository

yum install createrepo

yum install yum-utils

Step 3: Create a Directory to Store the Repositories

mkdir –p /var/www/html/repos/{base,centosplus,extras,updates}

Step 4: Synchronize HTTP Repositories

reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/var/www/html/repos/

reposync -g -l -d -m --repoid=centosplus --newest-only --download-metadata --download_path=/var/www/html/repos/

reposync -g -l -d -m --repoid=extras --newest-only --download-metadata --download_path=/var/www/html/repos/

reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/var/www/html/repos/

Step 5: Create the New Repository

createrepo /var/www/html

Step 6: Setup Local Yum Repository on Client System

Create and edit a new config file:

In the new file, enter the command (replacing the IP address with the IP address of your server):

[remote]
name=RHEL Apache
enabled=1
gpgcheck=0

Finally, save the file and exit.
]
Test the Configuration

While still on the client system, run a command to install a package with the yum package manager:

yum install httpd

For NGINX

#yum install nginx -y

#systemctl start nginx
#systemctl enable nginx
#systemctl status nginx

#yum install createrepo yum-utils

#mkdir -p /var/www/html/repos/{base,centosplus,extras,updates}

# reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/var/www/html/repos/
# reposync -g -l -d -m --repoid=centosplus --newest-only --download-metadata --download_path=/var/www/html/repos/
# reposync -g -l -d -m --repoid=extras --newest-only --download-metadata --download_path=/var/www/html/repos/
# reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/var/www/html/repos/

server {
listen 80;
server_name name or ip for server;
root /var/www/html/repos;
location / {
autoindex on; #enable listing of directory index
}
}

For Cron Script

#!/bin/bash
##specify all local repositories in a single variable
LOCAL_REPOS=”base centosplus extras updates”
##a loop to update repos one at a time
for REPO in ${LOCAL_REPOS}; do
reposync -g -l -d -m --repoid=$REPO --newest-only --download-metadata --download_path=/var/www/html/repos/
done

[local-base]
name=CentOS Base
gpgcheck=0
enabled=1

[local-centosplus]
name=CentOS CentOSPlus
gpgcheck=0
enabled=1

[local-extras]
name=CentOS Extras
gpgcheck=0
enabled=1

[local-updates]
name=CentOS Updates
gpgcheck=0
enabled=1

Test the configuration

#yum repolist
#yum repolist all
Рекомендации по теме
Комментарии
Автор

You’re awesome homez!!! You saved me an hour of headache…

yani.e
Автор

Hello

How to add remi repository on the server?
And how could i install package on the client side from specific repo
For Example:
I need to install php72 which located in remi repo..how this could be done on the client side?

amrelkhedewy
Автор

I would like to add epel repository also, i'm wondering how I can add this, I imagine I have to create another folder for example epel but my question is : do I have to download epel packages to a folder "epel" or I have this in the folder "extras " ?

Michelito
Автор

Hello,
How to Verify that this package can be installed from your repo?

samiulhaqmalik
Автор

I have created a folder called packages In /var/www/html/ and copied some .rpm packages to it. Then changed selinux context to httpd_sys_content_t.
Also added http in firewall.

On the client machine I created a repo file "new.repo" in /etc/yum.repos.d/
The repo file contains
[new]
name = newrepo
enabled = 1
gpgcheck = 0

Then I cleaned the yum cache using
Yum clean all
And then I tried to list repos using
Yum repolist all
But it says the repo file is disabled.
I tried everything but it's still disabled



Please help

lifeinframesdt
Автор

hey lazy admin... why we do gpgcheck= 0 can you tell me... i am sorta new to this thing..

ahmedjarral
Автор

you are best, what best time to talk to you.

salmanzafar