httpd Kompilierung und Installation und sed Tools

Softwareinstallation und Sed Tool

1. Softwareinstallation

1.1 Selbst erstelltes Yum Warehouse, bei dem es sich um eine Netzwerkquelle bzw. eine lokale Quelle handelt

1.1.1 Lokale Quelleneinstellungen:

Laden Sie die ISO-Datei für die virtuelle Maschine
httpd Kompilierung und Installation und sed Tools
httpd Kompilierung und Installation und sed Tools

# lsblk   #查看光盘设备/dev/sr0
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  120G  0 disk
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0  117G  0 part /
sdb      8:16   0   20G  0 disk
├─sdb1   8:17   0    2G  0 part /data/da2
├─sdb2   8:18   0    1G  0 part
└─sdb3   8:19   0    1G  0 part
sr0     11:0    1  9.6G  0 rom
# mount /dev/sr0 /mnt     #挂载光盘到/mnt
mount: /dev/sr0 is write-protected, mounting read-only
# cd /etc/yum.repos.d/
# vim CentOS-Base.repo
[CentOS-Base.repo]
name=CentOS-Base
baseurl=file:///mnt
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
CentOS-Base.repo                                                                                                             | 3.6 kB  00:00:00
(1/2): CentOS-Base.repo/group_gz                                                                                             | 153 kB  00:00:00
(2/2): CentOS-Base.repo/primary_db                                                                                           | 6.1 MB  00:00:00
repo id                                                                  repo name                                                            status
CentOS-Base.repo                                                         CentOS-Base                                                          10,070
repolist: 10,070
[root@localhost yum.repos.d]#

# yum install autofs  #安装autofs软件实现光盘自动挂载
# systemctl enable --now autofs
# vim  /etc/yum.repos.d/CentOS-Base.repo
[CentOS-Base.repo]
name=CentOS-Base
baseurl=file:///misc/cd
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

1.1.2 Aliyun-Quelleneinstellungen

Besuchen Sie die Website https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11p84Dq9 und folgen Sie den Anweisungen auf der Website:

Hinweis: Ändern Sie CentOS-Base.repo in der ursprünglichen Beschreibung in CentOS-Base.aliyun.repo, um ein Überschreiben von Dateien zu vermeiden

# wget -O /etc/yum.repos.d/CentOS-Base.aliyun.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2020-12-29 10:46:09--  https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 42.7.48.238, 42.7.48.239, 42.7.48.248, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|42.7.48.238|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.aliyun.repo’

100%[==========================================================================================================>] 2,523       --.-K/s   in 0s

2020-12-29 10:46:09 (152 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.aliyun.repo’ saved [2523/2523]

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
CentOS-Base.repo                                                                                                                            | 3.6 kB  00:00:00
base                                                                                                                                        | 3.6 kB  00:00:00
extras                                                                                                                                      | 2.9 kB  00:00:00
updates                                                                                                                                     | 2.9 kB  00:00:00
repo id                                                            repo name                                                                                 status
CentOS-Base.repo                                                   CentOS-Base                                                                               10,070
base/7/x86_64                                                      CentOS-7 - Base - mirrors.aliyun.com                                                      10,072
extras/7/x86_64                                                    CentOS-7 - Extras - mirrors.aliyun.com                                                       448
updates/7/x86_64                                                   CentOS-7 - Updates - mirrors.aliyun.com                                                    1,155
repolist: 21,745

Erhöhen Sie die EPEL-Quelle

# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2020-12-29 10:51:46--  http://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 42.7.48.242, 42.7.48.241, 42.7.48.243, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|42.7.48.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 664 [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel.repo’

100%[=========================================================================================================================>] 664         --.-K/s   in 0s

2020-12-29 10:51:47 (44.5 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [664/664]

# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel                                                                                                                                        | 4.7 kB  00:00:00
(1/2): epel/x86_64/primary_db                                                                                                               | 6.9 MB  00:00:04
(2/2): epel/x86_64/updateinfo                                                                                                               | 1.0 MB  00:00:15
repo id                                                        repo name                                                                        status
CentOS-Base.repo                                             CentOS-Base                                                                       10,070
base/7/x86_64                                                CentOS-7 - Base - mirrors.aliyun.com                                             10,072
epel/x86_64                                          Extra Packages for Enterprise Linux 7 - x86_64                                           13,501
extras/7/x86_64                                       CentOS-7 - Extras - mirrors.aliyun.com                                                    448
updates/7/x86_64                                     CentOS-7 - Updates - mirrors.aliyun.com                                                    1,155
repolist: 35,246

1.2 Kompilieren und installieren Sie http2.4, um einen normalen Zugriff zu realisieren

Besuchen Sie die Website http://httpd.apache.org/, laden Sie die komprimierte Datei httpd-2.4.46.tar.bz2 herunter und laden Sie sie auf den Server hoch. Befolgen Sie die Anweisungen in der INSTLL-Datei, um apr und apr-util von http://apr.apache.org/ herunterzuladen.

# mkdir -p  /usr/src/httpd
# mkdir -p /app/httpd244
# mv  apr-1.7.0/* /usr/src/httpd/httpd-2.4.46/srclib/apr
# mv apr-util-1.6.1/* /usr/src/httpd/httpd-2.4.46/srclib/apr-util/
# cd  /usr/src/httpd
# tar xvf httpd-2.4.46.tar.bz2
# cd /usr/src/httpd/httpd-2.4.46

Installieren Sie die beim Kompilieren verwendete Software

# yum -y install gcc make pcre-devel openssl-devel expat-devel

Kompilieren und installieren

# cd /usr/src/httpd/httpd-2.4.46
# ./configure
# make && make install

Nachfolgende Einstellungen

# setenforce 0
# vim /etc/sysconfig/selinux
SELINUX=disabled    #关闭Selinux

# systemctl stop firewalld.service   #关闭iptables

# vim  /etc/profile.d/httpd.sh  # 设置apachectl路径及自动启动httpd
PATH=$PATH:/app/httpd244/bin
export PATH
/app/httpd244/bin/apachectl restart

# vim /etc/man_db.conf  #设置man帮助路径
MANDATORY_MANPATH           /app/httpd244/man

# vim /app/httpd244/conf/httpd.conf  #更改httpd启动用户、用户组
User apache
Group apache

Zwei Anwendungsbeispiele für sed-Werkzeuge

2.1 Verwenden Sie sed, um die IPv4-Adresse des Computers im Befehl ifconfig zu ermitteln

# ifconfig|sed -n '2p'|sed -r 's/(^[^0-9]+)([0-9.]+)(.*)/\2/'

2.2 Löschen Sie alle # und Leerzeichen am Zeilenanfang, beginnend mit # und gefolgt von mindestens einem Leerzeichen in der Datei / etc / fstab

# sed -r 's/^#[[:space:]]+//' fstab

2.3 Verarbeiten Sie den Pfad / etc / fstab und rufen Sie mit dem Befehl sed den Verzeichnisnamen und den Basisnamen ab

# echo /etc/fstab | sed -r 's/(^\/.*\/)(.*)/\1/'  #取出目录名
# echo /etc/fstab | sed -r 's/(^\/.*\/)(.*)/\2/'  #取出基名

Ich denke du magst

Origin blog.51cto.com/12302225/2576812
Empfohlen
Rangfolge