Linux 练习6

1、自建yum仓库,分别为网络源和本地源

##### Server:
[19:51:42 root@Centos7 yum.repos.d]#yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                                    | 3.6 kB  00:00:00     
extras                                                                                                  | 2.9 kB  00:00:00     
updates                                                                                                 | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                                             | 4.7 MB  00:00:01     
Package httpd-2.4.6-97.el7.centos.x86_64 already installed and latest version
Nothing to do
[19:52:20 root@Centos7 yum.repos.d]#systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[20:00:40 root@Centos7 yum.repos.d]#mkdir /var/www/html/centos/7 -pv
mkdir: created directory ‘/var/www/html/centos/7’
[20:01:11 root@Centos7 yum.repos.d]#mount /dev/sr0 /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[20:01:56 root@Centos7 yum.repos.d]#cp -a /mnt/* /var/www/html/centos/7
[20:05:28 root@Centos7 yum.repos.d]#ll /var/www/html/centos/7
[21:54:41 root@Centos7 ~]#ll /etc/yum.repos.d
total 8
drwxr-xr-x 2 root root  187 Dec 31 21:34 backup
-rw-r--r-- 1 root root 2059 Dec 31 21:54 CentOS-Base.repo
-rw-r--r-- 1 root root  664 May 11  2018 epel.repo

[22:47:11 root@Centos7 ~]#yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * updates: mirrors.aliyun.com
repo id                                          repo name                                                               status
base/7/x86_64                                    base                                                                    10,072
epel/x86_64                                      epel                                                                    13,504
extras/7/x86_64                                  extras                                                                     448
updates/7/x86_64                                 CentOS-7 - Updates - mirrors.aliyun.com                                  1,155
repolist: 25,179

[23:04:03 root@Centos7 ~]#cat /etc/yum.repos.d/CentOS-Base.repo

[base]
name=base
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        file:///var/www/html/centos/7
        
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

.....


[21:58:53 root@Centos7 ~]reposync --repoid=extras --download-metadata -p
/var/www/html/centos
##执行上述命令两遍都没有metedata数据文件,只能createrepo 手动创建
[22:30:10 root@Centos7 yum.repos.d]#ls /var/www/html/centos/
7  extras
[22:30:30 root@Centos7 yum.repos.d]#ls /var/www/html/centos/extras
Packages
[22:30:39 root@Centos7 yum.repos.d]#cd  /var/www/html/centos/extras
[22:30:54 root@Centos7 extras]#ll
total 32
drwxr-xr-x 2 root root 28672 Dec 31 22:30 Packages
[22:31:00 root@Centos7 extras]#cd Packages
[22:31:06 root@Centos7 Packages]#ll
total 764368
-rw-r--r-- 1 root root   938112 Dec  1  2018 atomic-1.22.1-26.gitb507039.el7.centos.x86_64.rpm
-rw-r--r-- 1 root root   938268 Sep 16  2019 atomic-1.22.1-29.gitb507039.el7.x86_64.rpm
-rw-r--r-- 1 root root   939208 Apr 29  2020 atomic-1.22.1-33.gitb507039.el7_8.x86_64.rpm
-rw-r--r-- 1 root root    35968 Dec  1  2018 atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64.rpm
-rw-r--r-- 1 root root    36140 Sep 16  2019 atomic-registries-1.22.1-29.gitb507039.el7.x86_64.rpm
....
[22:31:12 root@Centos7 Packages]#createrepo .
Spawning worker 0 with 224 pkgs
Spawning worker 1 with 224 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[22:31:36 root@Centos7 Packages]#ll
total 764372
-rw-r--r-- 1 root root   938112 Dec  1  2018 atomic-1.22.1-26.gitb507039.el7.centos.x86_64.rpm
-rw-r--r-- 1 root root   938268 Sep 16  2019 atomic-1.22.1-29.gitb507039.el7.x86_64.rpm
-rw-r--r-- 1 root root   939208 Apr 29  2020 atomic-1.22.1-33.gitb507039.el7_8.x86_64.rpm
...
drwxr-xr-x 2 root root     4096 Dec 31 22:31 repodata

[21:58:53 root@Centos7 ~]#hostname -I
10.0.0.206 192.168.122.1 
[22:33:58 root@Centos7 ~]#systemctl stop firewalld.service

##### client:
[22:54:47 root@centos7 rpm-gpg]#ll /etc/yum.repos.d
total 4
drwxr-xr-x. 2 root root 220 Dec 29 20:14 backup
drwxr-xr-x. 2 root root  96 Dec 31 19:47 backup2
-rw-r--r--. 1 root root 186 Dec 31 22:42 basetest.repo
[22:55:00 root@centos7 rpm-gpg]#cat /etc/yum.repos.d/basetest.repo
[Base]
name=base
baseurl=http://10.0.0.206/centos/7
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=extras
baseurl=http://10.0.0.206/centos/extras/Packages

[22:55:26 root@centos7 rpm-gpg]#yum --disablerepo=* --enablerepo=extras list available
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
WALinuxAgent.noarch                                            2.2.46-2.el7_9                                            extras
atomic.x86_64                                                  1:1.22.1-33.gitb507039.el7_8                              extras
atomic-registries.x86_64                                       1:1.22.1-33.gitb507039.el7_8                              extras
buildah.x86_64                                                 1.11.6-11.el7_8                                           extras
....
storaged-iscsi.x86_64                                          2.5.2-4.el7                                               extras
storaged-lvm2.x86_64                                           2.5.2-4.el7                                               extras
swig3-doc.noarch                                               3.0.12-17.el7                                             extras
swig3-gdb.x86_64                                               3.0.12-17.el7                                             extras
uboot-images-armv7.noarch                                      2019.07-3.el7                                             extras
uboot-images-armv8.noarch                                      2019.07-3.el7                                             extras
uboot-tools.x86_64                                             2019.07-3.el7                                             extras



[22:47:21 root@centos7 yum.repos.d]#yum -y install swig3
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package swig3.x86_64 0:3.0.12-17.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
 Package                    Arch                        Version                              Repository                   Size
===============================================================================================================================
Installing:
 swig3                      x86_64                      3.0.12-17.el7                        extras                      1.4 M

Transaction Summary
===============================================================================================================================
Install  1 Package

Total download size: 1.4 M
Installed size: 5.6 M
Downloading packages:
No Presto metadata available for extras
swig3-3.0.12-17.el7.x86_64.rpm                                                                          | 1.4 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : swig3-3.0.12-17.el7.x86_64                                                                                  1/1 
  Verifying  : swig3-3.0.12-17.el7.x86_64                                                                                  1/1 

Installed:
  swig3.x86_64 0:3.0.12-17.el7                                                                                                 

Complete!

EPEL 配置
Server:

[00:54:18 root@Centos7 Packages]#reposync --repoid=epel --download-metadata -p /var/www/html

[09:56:58 root@Centos7 epel]#ll
total 1532
-rw-r--r--  1 root root   97633 Dec 31 23:25 37a4ee8f1b6e4f343c895b0779d82064a6b5db59f18affd9b8c2d526e1d7a2ab-comps-Everything.x86_64.xml.gz
-rw-r--r--  1 root root  398079 Dec 31 23:25 48de8dae6e8fb38f0fa7c6f2ecb5ed9a0b69794ced5f091c774350d1d8d2d58e-comps-Everything.x86_64.xml
-rw-r--r--  1 root root    1797 Dec 31 23:25 6e63d33e8cfbbe7011afded533ab9ec9cdbc3daf473c7866f05785e52824ce42-prestodelta.xml.gz
-rw-r--r--  1 root root 1056977 Dec 31 23:25 f29a4036ac57bc676f08a236742584ebeeab1c6cbf47c86d80676642b25ecbbe-updateinfo.xml.bz2
drwxr-xr-x 33 root root     285 Dec 31 23:25 Packages
-rw-r--r--  1 root root    1662 Jun 21  2014 RPM-GPG-KEY-EPEL-7
##没有metadata 文件生成,手动创建metadata.repo
[10:00:22 root@Centos7 epel]#createrepo .
Spawning worker 0 with 6752 pkgs
Spawning worker 1 with 6752 pkgs


Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete



[23:35:45 root@Centos7 epel]#wget -P /var/www/html/epel/ https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
--2020-12-31 23:37:07--  https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 221.236.11.248, 182.140.218.243, 125.64.1.228, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|221.236.11.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1662 (1.6K) [application/octet-stream]
Saving to: ‘/var/www/html/epel/RPM-GPG-KEY-EPEL-7’

100%[=====================================================================================>] 1,662       --.-K/s   in 0s      

2020-12-31 23:37:09 (123 MB/s) - ‘/var/www/html/epel/RPM-GPG-KEY-EPEL-7’ saved [1662/1662]




##### client:
[23:31:13 root@centos7 yum.repos.d]#cat basetest.repo
[Base]
name=base
baseurl=http://10.0.0.206/centos/7
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=extras
baseurl=http://10.0.0.206/centos/extras/Packages
[epel]
name=epel
baseurl=http://10.0.0.206/epel
gpgkey=http://10.0.0.206/epel/RPM-GPG-KEY-EPEL-7

[10:05:15 root@centos7 html]#yum -y install zvbi
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel                                                                                                    | 2.9 kB  00:00:00     
epel/primary_db                                                                                         | 6.8 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package zvbi.x86_64 0:0.2.35-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
 Package                    Arch                         Version                              Repository                  Size
===============================================================================================================================
Installing:
 zvbi                       x86_64                       0.2.35-1.el7                         epel                       415 k

Transaction Summary
===============================================================================================================================
Install  1 Package

Total download size: 415 k
Installed size: 1.3 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/zvbi-0.2.35-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for zvbi-0.2.35-1.el7.x86_64.rpm is not installed
zvbi-0.2.35-1.el7.x86_64.rpm                                                                            | 415 kB  00:00:00     
Retrieving key from http://10.0.0.206/epel/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 From       : http://10.0.0.206/epel/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : zvbi-0.2.35-1.el7.x86_64                                                                                    1/1 
  Verifying  : zvbi-0.2.35-1.el7.x86_64                                                                                    1/1 

Installed:
  zvbi.x86_64 0:0.2.35-1.el7                                                                                                   

Complete!

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

[20:15:35 root@bear httpd-2.4.46]#wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2

[20:15:35 root@bear httpd-2.4.46]#tar xvf httpd-2.4.46.tar.bz2 -C /usr/local/src
[20:21:11 root@bear httpd-2.4.46]#cd /usr/local/src
[20:21:11 root@bear httpd-2.4.46]#cd httpd-2.4.46
[20:22:21 root@bear httpd-2.4.46]#cat README
[20:22:29 root@bear httpd-2.4.46]#cat INSTALL
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

[20:21:11 root@bear httpd-2.4.46]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
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.
[20:38:12 root@bear httpd-2.4.46]#cat INSTALL | grep -i apr
            * Consider if you want to use a previously installed APR and
              APR-Util (such as those provided with many OSes) or if you
              need to use the APR and APR-Util from the apr.apache.org
              unpack them to ./srclib/apr and ./srclib/apr-util (no
              ./configure's --with-included-apr option. This is required
              if you don't have the compiler which the system APR was
              possibility of version or compile-option mismatches with APR
              and APR-Util code. As a convenience, prepackaged source-code
              bundles of APR and APR-Util are occasionally also provided

[20:38:37 root@bear httpd-2.4.46]#yum search apr*
Last metadata expiration check: 3:11:06 ago on Mon 04 Jan 2021 05:28:39 PM CST.
=================================================== Name & Summary Matched: apr* ===================================================
apr-devel.i686 : APR library development kit
apr-devel.x86_64 : APR library development kit
apr-util-ldap.x86_64 : APR utility library LDAP support
apr-util-odbc.x86_64 : APR utility library ODBC DBD driver
apr-util-devel.i686 : APR utility library development kit
apr-util-devel.x86_64 : APR utility library development kit
apr-util-bdb.i686 : APR utility library Berkeley DB driver
apr-util-bdb.x86_64 : APR utility library Berkeley DB driver
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver
apr-util-sqlite.x86_64 : APR utility library SQLite DBD driver
apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver
apr-util-openssl.i686 : APR utility library OpenSSL crypto support
apr-util-openssl.x86_64 : APR utility library OpenSSL crypto support
======================================================== Name Matched: apr* ========================================================
apr.i686 : Apache Portable Runtime library
apr.x86_64 : Apache Portable Runtime library
apr-util.i686 : Apache Portable Runtime Utility library
apr-util.x86_64 : Apache Portable Runtime Utility library

[20:39:45 root@bear httpd-2.4.46]#yum -y install apr-devel.x86_64 apr-util-devel.x86_64
Last metadata expiration check: 3:13:30 ago on Mon 04 Jan 2021 05:28:39 PM CST.
Dependencies resolved.
====================================================================================================================================
 Package                            Architecture             Version                              Repository                   Size
====================================================================================================================================
Installing:
 apr-devel                          x86_64                   1.6.3-9.el8                          appstream                   246 k
 apr-util-devel                     x86_64                   1.6.1-6.el8                          appstream                    86 k
Installing dependencies:
 apr                                x86_64                   1.6.3-9.el8                          appstream                   125 k
 apr-util                           x86_64                   1.6.1-6.el8                          appstream                   105 k
 cyrus-sasl-devel                   x86_64                   2.1.27-1.el8                         base                        128 k
 expat-devel                        x86_64                   2.2.5-3.el8                          base                         55 k
 libdb-devel                        x86_64                   5.3.28-37.el8                        appstream                    46 k
 openldap-devel                     x86_64                   2.4.46-11.el8_1                      base                        811 k
Installing weak dependencies:
 apr-util-bdb                       x86_64                   1.6.1-6.el8                          appstream                    25 k
 apr-util-openssl                   x86_64                   1.6.1-6.el8                          appstream                    27 k

Transaction Summary
====================================================================================================================================
Install  10 Packages
....
[20:55:38 root@bear httpd-2.4.46]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
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... no
configure: error: in `/usr/local/src/httpd-2.4.46':
configure: error: C compiler cannot create executables
See `config.log' for more details
[20:56:23 root@bear httpd-2.4.46]#cat config.log
configure:4236: Configuring Apache Portable Runtime library...
configure:4238: 
configure:4279: checking for APR
configure:4424: result: yes
configure:4684: 
configure:4686: Configuring Apache Portable Runtime Utility library...
configure:4688: 
configure:4725: checking for APR-util
configure:4804: result: yes
configure:5065: checking for gcc
configure:5092: result: gcc
configure:5321: checking for C compiler version
configure:5330: gcc --version >&5
....
[20:58:12 root@bear httpd-2.4.46]#dnf -y install gcc
Last metadata expiration check: 0:05:15 ago on Mon 04 Jan 2021 08:54:01 PM CST.
Dependencies resolved.
====================================================================================================================================
 Package                            Architecture              Version                            Repository                    Size
====================================================================================================================================
Installing:
 gcc                                x86_64                    8.3.1-5.el8.0.2                    appstream                     23 M
Installing dependencies:
 cpp                                x86_64                    8.3.1-5.el8.0.2                    appstream                     10 M
 glibc-devel                        x86_64                    2.28-101.el8                       base                         1.0 M
 glibc-headers                      x86_64                    2.28-101.el8                       base                         473 k
 isl                                x86_64                    0.16.1-6.el8                       appstream                    841 k
 kernel-headers                     x86_64                    4.18.0-193.el8                     base                         4.0 M
 libxcrypt-devel                    x86_64                    4.1.1-4.el8                        base                          25 k

Transaction Summary
====================================================================================================================================
Install  7 Packages

Total size: 40 M
Installed size: 98 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                            1/1 
  Installing       : isl-0.16.1-6.el8.x86_64                                                                                    1/7 
  Running scriptlet: isl-0.16.1-6.el8.x86_64                                                                                    1/7 
  Installing       : cpp-8.3.1-5.el8.0.2.x86_64                                                                                 2/7 
  Running scriptlet: cpp-8.3.1-5.el8.0.2.x86_64                                                                                 2/7 
  Installing       : kernel-headers-4.18.0-193.el8.x86_64                                                                       3/7 
  Running scriptlet: glibc-headers-2.28-101.el8.x86_64                                                                          4/7 
  Installing       : glibc-headers-2.28-101.el8.x86_64                                                                          4/7 
  Installing       : libxcrypt-devel-4.1.1-4.el8.x86_64                                                                         5/7 
  Installing       : glibc-devel-2.28-101.el8.x86_64                                                                            6/7 
  Running scriptlet: glibc-devel-2.28-101.el8.x86_64                                                                            6/7 
  Installing       : gcc-8.3.1-5.el8.0.2.x86_64                                                                                 7/7 
  Running scriptlet: gcc-8.3.1-5.el8.0.2.x86_64                                                                                 7/7 
  Verifying        : glibc-devel-2.28-101.el8.x86_64                                                                            1/7 
  Verifying        : glibc-headers-2.28-101.el8.x86_64                                                                          2/7 
  Verifying        : kernel-headers-4.18.0-193.el8.x86_64                                                                       3/7 
  Verifying        : libxcrypt-devel-4.1.1-4.el8.x86_64                                                                         4/7 
  Verifying        : cpp-8.3.1-5.el8.0.2.x86_64                                                                                 5/7 
  Verifying        : gcc-8.3.1-5.el8.0.2.x86_64                                                                                 6/7 
  Verifying        : isl-0.16.1-6.el8.x86_64                                                                                    7/7 

Installed:
  cpp-8.3.1-5.el8.0.2.x86_64                   gcc-8.3.1-5.el8.0.2.x86_64           glibc-devel-2.28-101.el8.x86_64               
  glibc-headers-2.28-101.el8.x86_64            isl-0.16.1-6.el8.x86_64              kernel-headers-4.18.0-193.el8.x86_64          
  libxcrypt-devel-4.1.1-4.el8.x86_64          

Complete!
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... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
[21:04:20 root@bear httpd-2.4.46]#yum search pcre
Last metadata expiration check: 0:10:28 ago on Mon 04 Jan 2021 08:54:01 PM CST.
==================================================== Name Exactly Matched: pcre ====================================================
pcre.x86_64 : Perl-compatible regular expression library
pcre.i686 : Perl-compatible regular expression library
=================================================== Name & Summary Matched: pcre ===================================================
pcre-cpp.i686 : C++ bindings for PCRE
pcre-cpp.x86_64 : C++ bindings for PCRE
pcre-utf16.i686 : UTF-16 variant of PCRE
pcre-utf16.x86_64 : UTF-16 variant of PCRE
pcre-utf32.i686 : UTF-32 variant of PCRE
pcre-utf32.x86_64 : UTF-32 variant of PCRE
pcre2-utf16.i686 : UTF-16 variant of PCRE2
pcre2-utf16.x86_64 : UTF-16 variant of PCRE2
pcre2-utf32.i686 : UTF-32 variant of PCRE2
pcre2-utf32.x86_64 : UTF-32 variant of PCRE2
pcre-devel.i686 : Development files for pcre
pcre-devel.x86_64 : Development files for pcre
postfix-pcre.x86_64 : Postfix PCRE map support
pcre2-devel.i686 : Development files for pcre2
pcre2-devel.x86_64 : Development files for pcre2
======================================================== Name Matched: pcre ========================================================
pcre2.x86_64 : Perl-compatible regular expression library
pcre2.i686 : Perl-compatible regular expression library
[21:04:29 root@bear httpd-2.4.46]#dnf -y install pcre-devel.x86_64
Last metadata expiration check: 0:11:20 ago on Mon 04 Jan 2021 08:54:01 PM CST.
Dependencies resolved.
====================================================================================================================================
 Package                          Architecture                 Version                             Repository                  Size
====================================================================================================================================
Installing:
 pcre-devel                       x86_64                       8.42-4.el8                          base                       551 k
Installing dependencies:
 pcre-cpp                         x86_64                       8.42-4.el8                          base                        47 k
 pcre-utf16                       x86_64                       8.42-4.el8                          base                       195 k
 pcre-utf32                       x86_64                       8.42-4.el8                          base                       186 k

Transaction Summary
====================================================================================================================================
Install  4 Packages

Total size: 978 k
Installed size: 2.6 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                            1/1 
  Installing       : pcre-utf32-8.42-4.el8.x86_64                                                                               1/4 
  Installing       : pcre-utf16-8.42-4.el8.x86_64                                                                               2/4 
  Installing       : pcre-cpp-8.42-4.el8.x86_64                                                                                 3/4 
  Installing       : pcre-devel-8.42-4.el8.x86_64                                                                               4/4 
  Running scriptlet: pcre-devel-8.42-4.el8.x86_64                                                                               4/4 
  Verifying        : pcre-cpp-8.42-4.el8.x86_64                                                                                 1/4 
  Verifying        : pcre-devel-8.42-4.el8.x86_64                                                                               2/4 
  Verifying        : pcre-utf16-8.42-4.el8.x86_64                                                                               3/4 
  Verifying        : pcre-utf32-8.42-4.el8.x86_64                                                                               4/4 

Installed:
  pcre-cpp-8.42-4.el8.x86_64     pcre-devel-8.42-4.el8.x86_64     pcre-utf16-8.42-4.el8.x86_64     pcre-utf32-8.42-4.el8.x86_64    

Complete!
[21:07:47 root@bear httpd-2.4.46]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl


 adding "-I$(top_srcdir)/modules/session" to INCLUDES
checking whether to enable mod_slotmem_shm... shared (most)
checking whether to enable mod_slotmem_plain... no
checking whether to enable mod_ssl... checking dependencies
checking for OpenSSL... checking for user-provided OpenSSL base directory... none
checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
[21:08:52 root@bear httpd-2.4.46]#yum -y install openssl-devel.x86_64
Last metadata expiration check: 0:15:16 ago on Mon 04 Jan 2021 08:54:01 PM CST.
Dependencies resolved.
====================================================================================================================================
 Package                                Architecture              Version                             Repository               Size
====================================================================================================================================
Installing:
 openssl-devel                          x86_64                    1:1.1.1c-15.el8                     base                    2.3 M
Installing dependencies:
 keyutils-libs-devel                    x86_64                    1.5.10-6.el8                        base                     48 k
 krb5-devel                             x86_64                    1.17-18.el8                         base                    549 k
 libcom_err-devel                       x86_64                    1.45.4-3.el8                        base                     38 k
 libkadm5                               x86_64                    1.17-18.el8                         base                    185 k
 libselinux-devel                       x86_64                    2.9-3.el8                           base                    199 k
 libsepol-devel                         x86_64                    2.9-1.el8                           base                     86 k
 libverto-devel                         x86_64                    0.3.0-5.el8                         base                     18 k
 pcre2-devel                            x86_64                    10.32-1.el8                         base                    605 k
 pcre2-utf16                            x86_64                    10.32-1.el8                         base                    228 k
 pcre2-utf32                            x86_64                    10.32-1.el8                         base                    220 k
 zlib-devel                             x86_64                    1.2.11-13.el8                       base                     57 k

Transaction Summary
====================================================================================================================================
Install  12 Packages

Total size: 4.5 M
Installed size: 8.1 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                            1/1 
  Installing       : zlib-devel-1.2.11-13.el8.x86_64                                                                           1/12 
  Installing       : pcre2-utf32-10.32-1.el8.x86_64                                                                            2/12 
  Installing       : pcre2-utf16-10.32-1.el8.x86_64                                                                            3/12 
  Installing       : pcre2-devel-10.32-1.el8.x86_64                                                                            4/12 
  Installing       : libverto-devel-0.3.0-5.el8.x86_64                                                                         5/12 
  Installing       : libsepol-devel-2.9-1.el8.x86_64                                                                           6/12 
  Installing       : libselinux-devel-2.9-3.el8.x86_64                                                                         7/12 
  Installing       : libkadm5-1.17-18.el8.x86_64                                                                               8/12 
  Installing       : libcom_err-devel-1.45.4-3.el8.x86_64                                                                      9/12 
  Installing       : keyutils-libs-devel-1.5.10-6.el8.x86_64                                                                  10/12 
  Installing       : krb5-devel-1.17-18.el8.x86_64                                                                            11/12 
  Installing       : openssl-devel-1:1.1.1c-15.el8.x86_64                                                                     12/12 
  Running scriptlet: openssl-devel-1:1.1.1c-15.el8.x86_64                                                                     12/12 
  Verifying        : keyutils-libs-devel-1.5.10-6.el8.x86_64                                                                   1/12 
  Verifying        : krb5-devel-1.17-18.el8.x86_64                                                                             2/12 
  Verifying        : libcom_err-devel-1.45.4-3.el8.x86_64                                                                      3/12 
  Verifying        : libkadm5-1.17-18.el8.x86_64                                                                               4/12 
  Verifying        : libselinux-devel-2.9-3.el8.x86_64                                                                         5/12 
  Verifying        : libsepol-devel-2.9-1.el8.x86_64                                                                           6/12 
  Verifying        : libverto-devel-0.3.0-5.el8.x86_64                                                                         7/12 
  Verifying        : openssl-devel-1:1.1.1c-15.el8.x86_64                                                                      8/12 
  Verifying        : pcre2-devel-10.32-1.el8.x86_64                                                                            9/12 
  Verifying        : pcre2-utf16-10.32-1.el8.x86_64                                                                           10/12 
  Verifying        : pcre2-utf32-10.32-1.el8.x86_64                                                                           11/12 
  Verifying        : zlib-devel-1.2.11-13.el8.x86_64                                                                          12/12 

Installed:
  keyutils-libs-devel-1.5.10-6.el8.x86_64      krb5-devel-1.17-18.el8.x86_64             libcom_err-devel-1.45.4-3.el8.x86_64     
  libkadm5-1.17-18.el8.x86_64                  libselinux-devel-2.9-3.el8.x86_64         libsepol-devel-2.9-1.el8.x86_64          
  libverto-devel-0.3.0-5.el8.x86_64            openssl-devel-1:1.1.1c-15.el8.x86_64      pcre2-devel-10.32-1.el8.x86_64           
  pcre2-utf16-10.32-1.el8.x86_64               pcre2-utf32-10.32-1.el8.x86_64            zlib-devel-1.2.11-13.el8.x86_64          

Complete!

[21:10:00 root@bear httpd-2.4.46]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
    Server Version: 2.4.46
    Install prefix: /apps/httpd24
    C compiler:     gcc
    CFLAGS:           -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E
[21:10:00 root@bear httpd-2.4.46]#echo $?
0
[21:12:49 root@bear httpd-2.4.46]#make -j 2 && make install
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/usr/local/src/httpd-2.4.46/modules/aaa/modules.mk:2: mod_authn_file.la] Error 1
make[4]: Leaving directory '/usr/local/src/httpd-2.4.46/modules/aaa'
make[3]: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1
make[3]: Leaving directory '/usr/local/src/httpd-2.4.46/modules/aaa'
make[2]: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1
make[2]: Leaving directory '/usr/local/src/httpd-2.4.46/modules'
make[1]: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:117: shared-build-recursive] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/usr/local/src/httpd-2.4.46'
make: *** [/usr/local/src/httpd-2.4.46/build/rules.mk:75: all-recursive] Error 1

[21:16:28 root@bear httpd-2.4.46]#dnf provides /usr/lib/rpm/redhat/
Last metadata expiration check: 0:22:37 ago on Mon 04 Jan 2021 08:54:01 PM CST.
redhat-rpm-config-122-1.el8.noarch : CentOS specific rpm configuration files
Repo        : appstream
Matched from:
Other       : /usr/lib/rpm/redhat/
[21:16:39 root@bear httpd-2.4.46]#dnf -y install redhat-rpm-config-122-1.el8
....
Installed:
  annobin-8.90-1.el8.0.1.x86_64               dwz-0.12-9.el8.x86_64                       efi-srpm-macros-3-2.el8.noarch            
  ghc-srpm-macros-1.4.2-7.el8.noarch          go-srpm-macros-2-16.el8.noarch              ocaml-srpm-macros-5-4.el8.noarch          
  openblas-srpm-macros-2-2.el8.noarch         perl-srpm-macros-1-25.el8.noarch            python-srpm-macros-3-38.el8.noarch        
  python3-rpm-macros-3-38.el8.noarch          qt5-srpm-macros-5.12.5-3.el8.noarch         redhat-rpm-config-122-1.el8.noarch        
  rust-srpm-macros-5-2.el8.noarch            

Complete!
[21:23:03 root@bear httpd-2.4.46]#make -j 2 
....
[21:22:49 root@bear httpd-2.4.46]#echo $?
0
[21:23:03 root@bear httpd-2.4.46]#make install
[21:24:15 root@bear httpd-2.4.46]#echo $?
0
[21:26:11 root@bear bin]#/apps/httpd24/bin/apachectl start
[21:40:28 root@bear bin]#curl http://10.0.0.217/
<html><body><h1>It works!</h1></body></html>

[21:58:53 root@bear bin]#ss -ntlp
LISTEN   0        128                    *:80                  *:*      users:(("httpd",pid=34463,fd=4))

[22:02:02 root@bear httpd24]#pwd
/apps/httpd24
[22:02:07 root@bear httpd24]#ll
total 36
drwxr-xr-x.  2 root root  262 Jan  4 21:24 bin
drwxr-xr-x.  2 root root  167 Jan  4 21:24 build
drwxr-xr-x.  2 root root   78 Jan  4 21:24 cgi-bin
drwxr-xr-x.  3 root root 4096 Jan  4 21:24 error
drwxr-sr-x.  2 root root   24 Aug  1 22:11 htdocs(更改页面显示内容此文件夹中修改)
drwxr-xr-x.  3 root root 8192 Jan  4 21:24 icons
drwxr-xr-x.  2 root root 4096 Jan  4 21:24 include
drwxr-xr-x.  2 root root   58 Jan  4 21:26 logs
drwxr-xr-x.  4 root root   30 Jan  4 21:24 man
drwxr-sr-x. 14 root root 8192 Aug  1 22:12 manual
drwxr-xr-x.  2 root root 4096 Jan  4 21:24 modules
[22:02:15 root@bear httpd24]#cd htdocs
[22:03:12 root@bear htdocs]#ll
total 4
-rw-r--r--. 1 root root 45 Jun 12  2007 index.html
[22:03:16 root@bear htdocs]#vim index.html
[22:03:57 root@bear htdocs]#curl 10.0.0.217
<html><body><h1>this is test web!</h1></body></html>

[22:04:09 root@bear htdocs]#cd -
/apps/httpd24
[22:04:49 root@bear httpd24]#echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[22:07:34 root@bear httpd24]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
[22:13:07 root@bear httpd24]#getent passwd apache
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
[22:13:27 root@bear httpd24]#vim /etc/httpd24/httpd.conf
#将user 和 group 都改成apache用户
[22:18:57 root@bear httpd24]#. /etc/profile.d/httpd24.sh

[22:27:08 root@bear httpd24]#apachectl start
httpd (pid 34847) already running

[22:27:26 root@bear httpd24]#kill -9 34847
# kill 以其他身份运行的httpd
[22:28:19 root@bear httpd24]#ps aux
apache     34848  0.0  0.4 2057952 9632 ?        Sl   22:27   0:00 /apps/httpd24/bin/httpd -k restart
apache     34849  0.0  0.6 2123488 13712 ?       Sl   22:27   0:00 /apps/httpd24/bin/httpd -k restart
apache     34850  0.0  0.6 2123488 13712 ?       Sl   22:27   0:00 /apps/httpd24/bin/httpd -k restart
脚本实现自动安装(不能跨越大版本安装以下在centos8 可以测试安装)

[23:03:15 root@bear ~]#cat install_httpd.sh
#!/bin/bash
#
#***********************
#Author:      stellatang
#Contact:     123456789
#Version:          1.0 
#Date:      2021-01-04
#Description:   The test script
#***********************
#安装前准备:关闭防火墙和SELinux
#1 安装包
rpm -q httpd && yum -y remove httpd
#2 下载并解压缩包
wget https://mirror.bit.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2 || { echo "download failed"; exit 10; }
dnf -y install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config || { echo "install failed"; exit20; } 
#2 下载并解压缩包

tar xvf httpd-2.4.43.tar.bz2 -C /usr/local/src
#3 配置
cd /usr/local/src/httpd-2.4.43/
./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl || { echo "configuration failed; eixt 30; }
#4 编译并安装
make -j 2 && make install || { echo "make failed"; exit 40; }
#5 配置环境
echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
. /etc/profile.d/httpd24.sh
#6运行
apachectl
#7 指定用apache用户运行
#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
#vim /etc/httpd24/httpd.conf  更改运行账号apache
#7生效和验证
#apachectl restart
#查看
ps aux

3、利用sed 取出ifconfig命令中本机的IPv4地址

[20:12:29 root@bear network-scripts]#ifconfig eth0 | sed -rn '2s/(.*inet )([0-9].*)(netmask.*)/\2/p'
10.0.0.217 

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[20:55:41 root@bear etc]#sed -ri.bak '/^#/s/^#//' /etc/fstab
[20:57:28 root@bear etc]#cat fstab


 /etc/fstab
 Created by anaconda on Sun Nov  8 10:22:18 2020

 Accessible filesystems, by reference, are maintained under '/dev/disk/'.
 See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.

 After editing this file, run 'systemctl daemon-reload' to update systemd
 units generated from this file.

UUID=d3d040bb-1831-4ea4-b8c6-417633d09e08 /                       xfs     defaults        0 0
UUID=66aea782-7004-452d-97c8-49c8a6664901 /boot                   ext4    defaults        1 2
UUID=bb5d54ba-6950-4559-834f-c90118dfa38e /data                   xfs     defaults        0 0
UUID=4c853aa7-d75b-4934-81b9-a8194772f38d swap                    swap    defaults  

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[21:10:08 root@bear etc]#echo "/etc/fstab" | sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/
[21:10:17 root@bear etc]#echo "/etc/fstab" | sed -r 's#(^/.*/)([^/]+/?)#\2#'
fstab
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,445评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,889评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,047评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,760评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,745评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,638评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,011评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,669评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,923评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,655评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,740评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,406评论 4 320
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,995评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,961评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,023评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,483评论 2 342

推荐阅读更多精彩内容

  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 12,131评论 2 34
  • 1、ls 文件属性:-:普通文件 d:目录文件 b:块设备 c:字符设备文件 l:符号连接...
    看清了也就看轻了彡阅读 1,999评论 0 2
  • 1、ls 文件属性:-:普通文件 d:目录文件 b:块设备 c:字符设备文件 l:符号连接...
    关于Linux底层开发阅读 417评论 0 2
  • 一、sed命令介绍: 1、含义:Stream Editor文本流编辑,sed是一个“非交互式的”面向字符流的编辑器...
    优果馥斯阅读 16,782评论 0 1
  • WK6 自建yum仓库,分别为网络源和本地源https://www.jianshu.com/p/07991a58a...
    大梦淋漓阅读 388评论 1 0