note_11.2_yum仓库

2019-02-26  本文已影响0人  人間失格_430b

如何使用光盘当作本地yum仓库:

  1. 挂载光盘至某目录,例如/media/cdrom
    mount -r -t iso9660 /dev/cdrom /media/cdrom
  2. 创建配置文件/etc/yum.repos.d/*.repo
    [CentOS7]
    name=
    baseurl=
    gpgcheck=
    enabled=
    

yum的repo配置文件中可用的变量:

$releasever: 当前OS的发行版的主版本号;
$arch: 平台;
$basearch:基础平台;
$YUM0-$YUM9

e.g. http://mirrors.magedu.com/centos/$releasever/$basearch/os


c/c++: gcc (GNU C Complier)

编译C源代码:

前提:提供开发工具及开发环境
  开发工具:make, gcc等
  开发环境:开发库,头文件
   glibc:标准库

通过“包组”提供开发组件
  CentOS 6: "Development Tools", "Server Platform Development",


安装后的配置:

  1. 导出二进制程序目录至PATH环境变量中;
    编辑文件/etc/profile.d/NAME.sh
      export PATH=/PATH/TO/BIN:$PATH

  2. 导出库文件路径
    编辑/etc/ld.so.conf.d/NAME.conf
      添加新的库文件所在目录至此文件中;

让系统重新生成缓存:
  ldconfig [-v]

  1. 导出头文件
    基于链接的方式实现:
      ln -sv

  2. 导出帮助手册
    编辑/etc/man.config文件
      添加一个MANPATH


练习:

1、yum的配置和使用;包括yum repository的创建;
2、编译安装apache;启动此服务;
下载httpd源码tar包

[root@localhost ~]# wget -P /tmp http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.38.tar.bz2
[root@localhost ~]# tar xjf /tmp/httpd-2.4.38.tar.bz2 
[root@localhost ~]# cd httpd-2.4.38/
[root@localhost httpd-2.4.38]# cat INSTALL 

  APACHE INSTALLATION OVERVIEW

  Quick Start - Unix
  ------------------

  For complete installation documentation, see [ht]docs/manual/install.html or
  http://httpd.apache.org/docs/2.4/install.html

     $ ./configure --prefix=PREFIX
     $ make
     $ make install
     $ PREFIX/bin/apachectl start

configure报错少APR

[root@localhost httpd-2.4.38]# ./configure \
>--prefix=/usr/local/apache2 \
> --sysconfdir=/etc/httpd2
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-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.

yum 安装APR

[root@localhost httpd-2.4.38]# yum -y install *apr*.x86_64*

./configure又报错少PCRE

[root@localhost httpd-2.4.38]# ./configure \
> --prefix=/usr/local/apache\
> --sysconfdir=/etc/httpd2
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-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-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... 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 http://pcre.org/

yum安装PCRE

[root@localhost httpd-2.4.38]# yum install *pcre*x86*

./configure完成

[root@localhost httpd-2.4.38]# ./configure \
> --prefix=/usr/local/apache \
> --sysconfdir=/etc/httpd2
....
configure: summary of build options:

    Server Version: 2.4.38
    Install prefix: /usr/local/apache
    C compiler:     gcc -std=gnu99
    CFLAGS:           -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E
[root@localhost httpd-2.4.38]# make
[root@localhost httpd-2.4.38]# make install

启动服务

[root@localhost httpd-2.4.38]# /usr/local/apache/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost httpd-2.4.38]# netstat -tan
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0      0 192.168.223.129:22      192.168.223.1:4543      ESTABLISHED
tcp        0     52 192.168.223.131:22      192.168.223.1:12950     ESTABLISHED
tcp        0      0 192.168.223.131:22      192.168.223.1:13127     ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN    
上一篇 下一篇

猜你喜欢

热点阅读