首页 > 系统 > Linux >

CentOS7通过apache搭建yum仓库

2017-04-21

CentOS7通过apache搭建yum仓库。

centOS7

1.安装apache

yum groupinstall -y 'Development Tools'
wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.25.tar.bz2
tar -xvf httpd-2.4.25.tar.bz2 
 cd httpd-2.4.25/
./configure --prefix=/opt/httpd --sysconfdir=/etc/httpd2.4/
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    configure: 
    configure: Configuring Apache Portable Runtime library...
    configure: 
    checking for APR... no
    configure: error: APR not found.  Please read the documentation.
#缺少apr
yum install apr-devel -y
./configure --prefix=/opt/httpd --sysconfdir=/etc/httpd2.4/
                checking for chosen layout... Apache
                checking for working mkdir -p... yes
                checking for grep that handles long lines and -e... /usr/bin/grep
                checking for egrep... /usr/bin/grep -E
                checking build system type... x86_64-unknown-linux-gnu
                checking host system type... x86_64-unknown-linux-gnu
                checking target system type... x86_64-unknown-linux-gnu
                configure: 
                configure: Configuring Apache Portable Runtime library...
                configure: 
                checking for APR... yes
                  setting CC to "gcc"
                  setting CPP to "gcc -E"
                  setting CFLAGS to "  -pthread"
                  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
                  setting LDFLAGS to " "
                configure: 
                configure: Configuring Apache Portable Runtime Utility library...
                configure: 
                checking for APR-util... no
                configure: error: APR-util not found.  Please read the documentation.
#缺少APR-util 
yum install -y apr-util-devel
./configure --prefix=/opt/httpd --sysconfdir=/etc/httpd2.4/

    configure: 
    checking for APR... yes
      setting CC to "gcc"
      setting CPP to "gcc -E"
      setting CFLAGS to "  -pthread"
      setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
      setting LDFLAGS to " "
    configure: 
    configure: Configuring Apache Portable Runtime Utility library...
    configure: 
    checking for APR-util... yes
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -E
    checking for gcc option to accept ISO C99... -std=gnu99
    checking for pcre-config... false
    configure: error: pcre-config for libpcre not found. PCRE is required and available from https://pcre.org/
# 缺少pcre
yum install -y  pcre-devel
./configure --prefix=/opt/httpd --sysconfdir=/etc/httpd2.4/
/opt/httpd/bin/apachectl start
netstat -tnl
[root@liyong: repodata]#  ps -ef|grep apache
root      27235   6025  0 00:43 pts/1    00:00:00 grep --color=auto apache
[root@liyong: repodata]# cd /etc/rc.d/init.d/
[432][root@liyong: init.d]# ll
total 32
-rw-r--r--. 1 root root 15131 Sep 12  2016 functions
-rwxr-xr-x. 1 root root  2989 Sep 12  2016 netconsole
-rwxr-xr-x. 1 root root  6643 Sep 12  2016 network
-rw-r--r--. 1 root root  1160 Mar  3 11:23 README
cat>>cd /etc/rc.d/init.d/httpd<

2. 创建yum仓库目录

cd htdocs/
[root@liyong: htdocs]# ll
total 4
-rw-r--r--. 1 root root 45 Jun 12  2007 index.html
添加新的rpm包
[root@liyong: htdocs]# mkdir -p repo/7
[root@liyong: htdocs]# cd repo/7/
 cp /misc/cd/Packages/tree-1.6.0-10.el7.x86_64.rpm ./
yum -y install createrepo
#初始化repodata索引文件
[root@liyong: 7]#createrepo ./
[root@liyong: 7]#ll
    Spawning worker 0 with 1 pkgs
    Spawning worker 1 with 0 pkgs
    Spawning worker 2 with 0 pkgs
    Spawning worker 3 with 0 pkgs
    Workers Finished
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    Generating sqlite DBs
    Sqlite DBs complete
[root@liyong: 7]# ll
    total 52
    drwxr-xr-x. 2 root root  4096 Apr 21 00:03 repodata
    -rw-r--r--. 1 root root 47508 Apr 20 23:41 tree-1.6.0-10.el7.x86_64.rpm

3. 添加yum源

cat>/etc/yum
yum/         yum.conf     yum.repos.d/ 
[root@liyong: repodata]# cat>/etc/yum.repos.d/http.repo< [http]
> name=http
> baseurl=https://172.16.255.19/repo/7/
> gpgcheck=1
> E
[root@liyong: repodata]# cat /etc/yum.repos.d/http.repo 
[http]
name=http
baseurl=https://172.16.255.19/repo/7/
gpgcheck=1
[root@liyong: repodata]#  yum --enablerepo=htpp --disablerepo=base,epel,ftp list 
[root@liyong: repodata]# yum clean all
[root@liyong: repodata]#yum repolist 可看到yum仓库里面有一个包
相关文章
最新文章
热点推荐