Description
Operating system: CentOS 6.x
IP Address: 192.168.21.188
Implementation Purpose: Synchronize the contents of the CentOS mirrored site to this server, and by configuring the HTTP server, can provide Yum services outside
Prepare the article:
First, install HTTP server
The HTTP service is provided here using the Nginx server
Ii. System Agreement
Nginx site root directory: / usr / local / nginx / html
Server execution script file storage directory: / home / crontab
Third, start Nginx directory browsing function
Vi / usr / local / nginx / conf / nginx.conf #Edit the configuration file, add the following below HTTP {:
AutoIndex on; #Enable nginx directory browsing function
Autoindex_exact_size off; #File size starts from KB
Autoindex_localtime on; #Display file modification time as server local time
: wq! #save, exit
Service Nginx Reload #Reload configuration
Reference: Nginx Open Directory browsing function
Http://www.111cn.net/archives/5051.html
System Yun-wei Www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Installation article:
First, create a mirrored file storage directory
Mkdir-p / usr / local / nginx / html / centos #CentOS official standard source
Mkdir-p / usr / local / nginx / html / repoforge # third-party rpmforge source
Mkdir-p / usr / local / nginx / html / epel # third-party epel source
Description: Create three folders to store CentOS official standard source, third party rpmforge source and Epel source separately
Two, determine the above three Yum source upstream source of synchronous mirror address
1, CentOS official standard Source: rsync: //mirrors.ustc.edu.cn/centos/
2, Rpmforge Source: rsync: //mirrors.ispros.com.bd/repoforge/
3, Epel Source: rsync: //mirrors.ustc.edu.cn/epel/
Note: The upstream Yum source must support the Rsync protocol, otherwise you cannot use rsync for synchronization.
Reference:
CentOS Official Standard Source:
Rsync: //mirrors.kernel.org/centos
Rpmforge Source:
http://apt.sw.be/
Rsync: //ftp-stud.fht-esslingen.de/dag
Epel Source:
http://mirrors.fedoraproject.org/publiclist/EPEL/
Rsync: //mirrors.kernel.org/fedora-epel
Three, create above three Yum source synchronization script, and set script to execute automatically
Mkdir-p / home / crontab #create directory
Vi / home / crontab / yum_rsync.sh #Add the following code
#! / bin / sh
/ USR / BIN / RSYNC-AVRT rsync: //mirrors.ustc.edu.cn/centos/--exclude-from=/usr/local/nginx/html/exclude_centos.list / usr / local / nginx / html / centos /
/ USR / BIN / RSYNC-AVRT rsync: //mirrors.ispros.com.bd/repoforge/--exclude-from=/usr/local/nginx/html/exclude_ repoforge.list / usr / local / nginx / html / repoforge /
/ USR / BIN / RSYNC-AVRT rsync: //mirrors.ustc.edu.cn/epel/--EXCLUDE-FROM=/USR/LOCAL/NGINX/HTML/EXCLUDE_EPEL.LIST/USR / local / nginx / html / epel /
: wq! #Save and exit
chmod + x / home / crontab / yum_rsync.sh #Add script execution permissions
Note: Before running this script, create a sync directory and directory list files that do not need to be synchronized
cd / usr / local / nginx / html / # Enter the directory
Touch Exclude_centos.list #Create file
Touch Exclude_repoforge.list #Create file
Touch Exclude_epel.list #Create file
Write directories that do not need to be synchronized into the corresponding file, one directory per line
For example:
VI exclude_epel.list
4 /
4as /
4es /
4ws /
: wq! #Save and exit
Iv. Adding scripts to perform tasks regularly
Vi / etc / crontab #Add the following code to the last line
0 1 * * * root / home / crontab / yum_rsync.sh #Set the script to run every day at 1am
: wq! #Save and exit
Service Crond Restart #Restart
Test article:
First, install rsync synchronization software
Yum Install rsync xinetd #Install
Vi / etc / xinetd.d / rsync #Edit configuration file, set power-on start rsync
Disable = no #Modify
/etc/init.d/xinetd start #Start (CentOS is xinetd to manage rsync services)
: wq! #Save and exit
Second, execute synchronization scripts
sh / home / crontab / yum_rsync.sh
Note: Wait for the script to complete, the first synchronization, the time spent relatively long!
Three, create three Yum source repo configuration file according to different version
Cd / etc / yum.repos.d / # Enter the directory
Mv / etc / yum.repos.d / centos-base.repo Centos-base.repo-bak
1, CentOS official standard Source:
CentOS 5.x Series:
Vi / etc / yum.repos.d / centos-base.repo #Add the following code
# Centos-base.repo
#
# The Mirror system uses the connecting IP address of the client and the
# Update status of each mirror to pick mirrors, are updated to and
# Geographically close to the client. You are should use this for CentOS updates
# Unless you are manually picking the other mirrors.
#
# If The mirrorlist = does not work for your, as a fall back you can try the
# remarked out Baseurl = line instead.
#
#
[Base]
name = centos- $ releasever-base-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/os/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = os
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-5
#released Updates
[Updates]
name = centos- $ releasever-updates-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/updates/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = updates
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-5
#packages used / produced in the builds but not released
[Addons]
name = centos- $ releasever-addons-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/addons/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = addons
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-5
#additional packages that useful
[Extras]
name = centos- $ releasever-extras-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/extras/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = extras
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-5
#additional packages that extend functionality of existing packages
[Centosplus]
name = centos- $ releasever-plus-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/centosplus/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = centosplus
Gpgcheck = 1
Enabled = 0
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-5
# contrib-packages by Centos Users
[Contrib]
name = centos- $ releasever-contrib-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/contrib/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = contrib
Gpgcheck = 1
Enabled = 0
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-5
: wq! #Save and exit
############################
CentOS 6.x Series:
Vi / etc / yum.repos.d / centos-base.repo #Add the following code
# Centos-base.repo
#
# The Mirror system uses the connecting IP address of the client and the
# Update status of each mirror to pick mirrors, are updated to and
# Geographically close to the client. You are should use this for CentOS updates
# Unless you are manually picking the other mirrors.
#
# If The mirrorlist = does not work for your, as a fall back you can try the
# remarked out Baseurl = line instead.
#
#
[Base]
name = centos- $ releasever-base-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/os/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = os
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
#released Updates
[Updates]
name = centos- $ releasever-updates-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/updates/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = updates
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
#additional packages that useful
[Extras]
name = centos- $ releasever-extras-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/extras/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = extras
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
#additional packages that extend functionality of existing packages
[Centosplus]
name = centos- $ releasever-plus-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/centosplus/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = centosplus
Gpgcheck = 1
Enabled = 0
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
# contrib-packages by Centos Users
[Contrib]
name = centos- $ releasever-contrib-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/contrib/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = contrib
Gpgcheck = 1
Enabled = 0
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
: wq! #Save and exit
############################
CentOS 7.x Series:
Vi / etc / yum.repos.d / centos-base.repo #Add the following code
# Centos-base.repo
#
# The Mirror system uses the connecting IP address of the client and the
# Update status of each mirror to pick mirrors, are updated to and
# Geographically close to the client. You are should use this for CentOS updates
# Unless you are manually picking the other mirrors.
#
# If The mirrorlist = does not work for your, as a fall back you can try the
# remarked out Baseurl = line instead.
#
#
[Base]
name = centos- $ releasever-base
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = os
baseurl = http: //192.168.21.188/centos/$releasever/os/$basearch/
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-7
#released Updates
[Updates]
name = centos- $ releasever-updates
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = updates
baseurl = http: //192.168.21.188/centos/$releasever/updates/$basearch/
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-7
#additional packages that useful
[Extras]
name = centos- $ releasever-extras
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = extras
baseurl = http: //192.168.21.188/centos/$releasever/extras/$basearch/
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-7
#additional packages that extend functionality of existing packages
[Centosplus]
name = centos- $ releasever-plus
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = centosplus
baseurl = http: //192.168.21.188/centos/$releasever/centosplus/$basearch/
Gpgcheck = 1
Enabled = 0
Gpgk ey = http: //192.168.21.188/centos/rpm-gpg-key-centos-7
: wq! #Save and exit
############################
or reference: Https://lug.ustc.edu.cn/wiki/mirrors/help/centos
Replace the http://mirrors.ustc.edu.cn/ inside with http://192.168.21.188/.
2, Rpmforge Source:
CentOS 5.x Series:
Vi / etc / yum.repos.d / rpmforge.repo #Add the following code
[Rpmforge]
Name = RHEL $ releasever-rpmforge.net-dag
BaseURL = http://192.168.21.188/repoforge/redhat/el5/en/$basearch/rpmforge
Enabled = 1
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-extras]
Name = RHEL $ releasever-rpmforge.net-extras
BaseURL = http://192.168.21.188/repoforge/redhat/el5/en/$basearch/extras
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-testing]
Name = RHEL $ releasever-rpmforge.net-testing
BaseURL = http://192.168.21.188/repoforge/redhat/el5/en/$basearch/testing
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
: wq! #Save and exit
############################
System Yun-wei Www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
CentOS 6.x Series:
Vi / etc / yum.repos.d / rpmforge.repo #Add the following code
[Rpmforge]
Name = RHEL $ releasever-rpmforge.net-dag
BaseURL = http://192.168.21.188/repoforge/redhat/el6/en/$basearch/rpmforge
Enabled = 1
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-extras]
Name = RHEL $ releasever-rpmforge.net-extras
BaseURL = http://192.168.21.188/repoforge/redhat/el6/en/$basearch/extras
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-testing]
Name = RHEL $ releasever-rpmforge.net-testing
BaseURL = http://192.168.21.188/repoforge/redhat/el6/en/$basearch/testing
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
: wq! #Save and exit
############################
CentOS 7.x Series:
Vi / etc / yum.repos.d / rpmforge.repo #Add the following code
[Rpmforge]
Name = RHEL $ releasever-rpmforge.net-dag
BaseURL = http://192.168.21.188/repoforge/redhat/el7/en/$basearch/rpmforge
Enabled = 1
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-extras]
Name = RHEL $ releasever-rpmforge.net-extras
BaseURL = http://192.168.21.188/repoforge/redhat/el7/en/$basearch/extras
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-testing]
Name = RHEL $ releasever-rpmforge.net-testing
BaseURL = http://192.168.21.188/repoforge/redhat/el7/en/$basearch/testing
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
: wq! #Save and exit
############################
3, Epel Source:
CentOS 5.x Series:
Vi / etc / yum.repos.d / epel.repo #Add the following code
[Epel]
Name = extra Packages for Enterprise Linux 5- $ basearch
baseurl = http: //192.168.21.188/epel/5/$basearch
Failovermethod = priority
Enabled = 1
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-5
[Epel-debuginfo]
Name = extra Packages for Enterprise Linux 5- $ basearch-debug
baseurl = http: //192.168.21.188/epel/5/$basearch/debug
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-5
Gpgcheck = 1
[Epel-source]
Name = extra Packages for Enterprise Linux 5- $ basearch-source
Baseurl = http: //192.168.21.188/epel/5/srpms
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-5
Gpgcheck = 1
: wq! #Save and exit
############################
CentOS 6.x Series:
Vi / etc / yum.repos.d / epel.repo #Add the following code
[Epel]
Name = extra Packages for Enterprise Linux 6- $ basearch
baseurl = http: //192.168.21.188/epel/6/$basearch
Failovermethod = priority
Enabled = 1
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-6
[Epel-debuginfo]
Name = extra Packages for Enterprise Linux 6- $ basearch-debug
baseurl = http: //192.168.21.188/epel/6/$basearch/debug
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-6
Gpgcheck = 1
[Epel-source]
Name = extra Packages for Enterprise Linux 6- $ basearch-source
Baseurl = http: //192.168.21.188/epel/6/srpms
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-6
Gpgcheck = 1
: wq! #Save and exit
############################
CentOS 7.x Series:
Vi / etc / yum.repos.d / epel.repo #Add the following code
[Epel]
Name = extra Packages for Enterprise Linux 7- $ basearch
baseurl = http: //192.168.21.188/epel/beta/7/$basearch
Failovermethod = priority
Enabled = 1
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-7
[Epel-debuginfo]
Name = extra Packages for Enterprise Linux 7- $ basearch-debug
baseurl = http: //192.168.21.188/epel/beta/7/$basearch/debug
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-7
Gpgcheck = 1
[Epel-source]
Name = extra Packages for Enterprise Linux 7- $ basearch-source
Baseurl = http: //192.168.21.188/epel/beta/7/srpms
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-7
Gpgcheck = 1
: wq! #Save and exit
############################
Test Yum source is configured correctly
1, the current system version is CentOS 6.x, take this as an example
cd / etc / yum.repos.d /
Mv / etc / yum.repos.d / centos-base.repo / etc / yum.repos.d / centos-base.repo.backup
VI Centos-base.repo #Add the following code
# Centos-base.repo
#
# The Mirror system uses the connecting IP address of the client and the
# Update status of each mirror to pick mirrors, are updated to and
# Geographically close to the client. You are should use this for CentOS updates
# Unless you are manually picking the other mirrors.
#
# If The mirrorlist = does not work for your, as a fall back you can try the
# remarked out Baseurl = line instead.
#
#
[Base]
name = centos- $ releasever-base-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/os/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = os
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
#released Updates
[Updates]
name = centos- $ releasever-updates-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/updates/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = updates
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
#additional packages that useful
[Extras]
name = centos- $ releasever-extras-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/extras/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = extras
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
#additional packages that extend functionality of existing packages
[Centosplus]
name = centos- $ releasever-plus-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/centosplus/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = centosplus
Gpgcheck = 1
Enabled = 0
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
# contrib-packages by Centos Users
[Contrib]
name = centos- $ releasever-contrib-huanqiu.com
baseurl = http: //192.168.21.188/centos/$releasever/contrib/$basearch/
#mirrorlist = http: //mirrorlist.centos.org/? release = $ releasever & arch = $ basearch & repo = contrib
Gpgcheck = 1
Enabled = 0
Gpgkey = http: //192.168.21.188/centos/rpm-gpg-key-centos-6
: wq! #Save and exit
############################
VI Rpmforge.repo #Add the following code
[Rpmforge]
Name = RHEL $ releasever-rpmforge.net-dag
BaseURL = http://192.168.21.188/repoforge/redhat/el6/en/$basearch/rpmforge
Enabled = 1
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-extras]
Name = RHEL $ releasever-rpmforge.net-extras
BaseURL = http://192.168.21.188/repoforge/redhat/el6/en/$basearch/extras
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
[Rpmforge-testing]
Name = RHEL $ releasever-rpmforge.net-testing
BaseURL = http://192.168.21.188/repoforge/redhat/el6/en/$basearch/testing
Enabled = 0
Protect = 0
Gpgkey = http: //192.168.21.188/repoforge/rpm-gpg-key-rpmforge
Gpgcheck = 1
: wq! #Save and exit
############################
VI Epel.repo #Add the following code
[Epel]
Name = extra Packages for Enterprise Linux 6- $ basearch
baseurl = http: //192.168.21.188/epel/6/$basearch
Failovermethod = priority
Enabled = 1
Gpgcheck = 1
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-6
[Epel-debuginfo]
Name = extra Packages for Enterprise Linux 6- $ basearch-debug
baseurl = http: //192.168.21.188/epel/6/$basearch/debug
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-6
Gpgcheck = 1
[Epel-source]
Name = extra Packages for Enterprise Linux 6- $ basearch-source
Baseurl = http: //192.168.21.188/epel/6/srpms
Failovermethod = priority
Enabled = 0
Gpgkey = http: //192.168.21.188/epel/rpm-gpg-key-epel-6
Gpgcheck = 1
: wq! #Save and exit
############################
System Yun-wei Www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Yum Clean all #Clear the current yum cache
Yum Makecache #cache package information in yum source
Yum Repolist #List packages available in yum source
2, use the Yum command to install the software
Yum Install PHP #test CentOS official standard source
Yum Install Htop #test rpmforge source
Yum Install Nginx #test epel source
To this end, build CentOS online yum source mirror server complete!