filmov
tv
How to Create Local Yum Repo on CentOS 7
![preview_player](https://i.ytimg.com/vi/mTWuhK-2Up8/maxresdefault.jpg)
Показать описание
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
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
Комментарии