第四周任务

1.本地yum仓库

1.首先将光驱中的镜像文件进行挂载(先将虚拟机的光盘载入)

[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# df -Th                          //查看下挂载
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        37G  7.5G   30G   21% /
devtmpfs                devtmpfs  977M     0  977M    0% /dev
tmpfs                   tmpfs     993M     0  993M    0% /dev/shm
tmpfs                   tmpfs     993M  9.1M  984M    1% /run
tmpfs                   tmpfs     993M     0  993M    0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  161M  854M   16% /boot
tmpfs                   tmpfs     199M  4.0K  199M    1% /run/user/42
tmpfs                   tmpfs     199M   52K  199M    1% /run/user/0
/dev/sr0                iso9660   4.3G  4.3G     0  100% /mnt 

2.切换到 yum.repo.d 目录 将自带的仓库移走,多个开启仓库文件可能会造成冲突无法使用

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/
[root@localhost yum.repos.d]# ls
bak

3.新建yum仓库文件

[root@localhost yum.repos.d]# vim abc.repo
[abc]
name=abc
baseurl=file:///mnt
enabled=1
gpgcheck=0
#gpgkey=file:etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7               //若gpgcheck=1

[root@localhost yum.repos.d]#yum clean all

4.网络源只需要更改源就可以了

[root@localhost yum.repos.d]# vim abc.repo
[abc]
name=abc
baseurl=https://mirrors.aliyun.com/centos/$releasever/
	   =https://mirrors.cloud.tencent.com/centos/$releasever/ 
	   =https://repo.huaweicloud.com/centos/$releasever/
	   =https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/
enabled=1
gpgcheck=0

[root@localhost yum.repos.d]#yum clean all

2.编译安装

[root@localhost ~]# mkdir /bianyi
[root@localhost ~]# cd /bianyi/
[root@localhost bianyi]# wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.48.tar.bz2
--2021-07-01 22:39:47--  https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.48.tar.bz2
正在解析主机 mirrors.bfsu.edu.cn (mirrors.bfsu.edu.cn)... 39.155.141.16, 2001:da8:20f:4435:4adf:37ff:fe55:2840
正在连接 mirrors.bfsu.edu.cn (mirrors.bfsu.edu.cn)|39.155.141.16|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:7194385 (6.9M) [application/octet-stream]
正在保存至: “httpd-2.4.48.tar.bz2”

100%[=========================================================>] 7,194,385   4.45MB/s 用时 1.5s   

2021-07-01 22:39:49 (4.45 MB/s) - 已保存 “httpd-2.4.48.tar.bz2” [7194385/7194385])
[root@localhost bianyi]tar xvf httpd-2.4.48.tar.bz2
[root@localhost bianyi]# ls
httpd-2.4.48  httpd-2.4.48.tar.bz2
[root@localhost bianyi]# cd httpd-2.4.48/
[root@localhost httpd-2.4.48]# ./configure \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--enable-mods-shared=most \
--with-mpm=worker \
--disable-cgid \
--disable-cgi
中间省略
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
无apr包安装即可
[root@localhost httpd-2.4.48]# yum install apr* -y
中间省略
作为依赖被升级:
  cyrus-sasl.x86_64 0:2.1.26-23.el7               cyrus-sasl-gssapi.x86_64 0:2.1.26-23.el7        
  cyrus-sasl-lib.x86_64 0:2.1.26-23.el7           cyrus-sasl-md5.x86_64 0:2.1.26-23.el7           
  cyrus-sasl-plain.x86_64 0:2.1.26-23.el7         cyrus-sasl-scram.x86_64 0:2.1.26-23.el7         
  expat.x86_64 0:2.1.0-12.el7                     libdb.x86_64 0:5.3.21-25.el7                    
  libdb-utils.x86_64 0:5.3.21-25.el7              openldap.x86_64 0:2.4.44-23.el7_9               

完毕!
[root@localhost httpd-2.4.48]# ./configure \
> --prefix=/usr/local/apache \
> --enable-so \
> --enable-rewrite \
> --enable-mods-shared=most \
> --with-mpm=worker \
> --disable-cgid \
> --disable-cgi
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/bianyi/httpd-2.4.48':
configure: error: C compiler cannot create executables
See `config.log' for more details
提示gcc 没有安装,安装即可
[root@localhost httpd-2.4.48]# yum install gcc* -y
中间省略
作为依赖被升级:
  glibc.x86_64 0:2.17-324.el7_9 glibc-common.x86_64 0:2.17-324.el7_9 libgcc.x86_64 0:4.8.5-44.el7
  libgomp.x86_64 0:4.8.5-44.el7 libstdc++.x86_64 0:4.8.5-44.el7
[root@localhost httpd-2.4.48]# ./configure \
> --prefix=/usr/local/apache \
> --enable-so \
> --enable-rewrite \
> --enable-mods-shared=most \
> --with-mpm=worker \
> --disable-cgid \
> --disable-cgi
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/
pcre没装安装即可
[root@localhost httpd-2.4.48]# yum install pcre* -y
中间省略
已安装:
  pcre-devel.x86_64 0:8.32-17.el7                  pcre-static.x86_64 0:8.32-17.el7               
  pcre-tools.x86_64 0:8.32-17.el7                  pcre2-devel.x86_64 0:10.23-2.el7               
  pcre2-static.x86_64 0:10.23-2.el7                pcre2-tools.x86_64 0:10.23-2.el7               
  pcre2-utf16.x86_64 0:10.23-2.el7                 pcre2-utf32.x86_64 0:10.23-2.el7               

完毕!
[root@localhost httpd-2.4.48]# ./configure \
> --prefix=/usr/local/apache \
> --enable-so \
> --enable-rewrite \
> --enable-mods-shared=most \
> --with-mpm=worker \
> --disable-cgid \
> --disable-cgi
中间省略
 Server Version: 2.4.48
    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.48]# make
等待编译完成
/modules/lua -I/bianyi/httpd-2.4.48/modules/proxy -I/bianyi/httpd-2.4.48/modules/http2 -I/bianyi/httpd-2.4.48/modules/session -I/bianyi/httpd-2.4.48/modules/ssl -I/bianyi/httpd-2.4.48/modules/test -I/bianyi/httpd-2.4.48/server -I/bianyi/httpd-2.4.48/modules/md -I/bianyi/httpd-2.4.48/modules/arch/unix -I/bianyi/httpd-2.4.48/modules/dav/main -I/bianyi/httpd-2.4.48/modules/generators -I/bianyi/httpd-2.4.48/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -std=gnu99  -pthread           -o mod_rewrite.la -rpath /usr/local/apache/modules -module -avoid-version  mod_rewrite.lo 
make[4]: 离开目录“/bianyi/httpd-2.4.48/modules/mappers”
make[3]: 离开目录“/bianyi/httpd-2.4.48/modules/mappers”
make[2]: 离开目录“/bianyi/httpd-2.4.48/modules”
make[2]: 进入目录“/bianyi/httpd-2.4.48/support”
make[2]: 离开目录“/bianyi/httpd-2.4.48/support”

make[1]: 离开目录“/bianyi/httpd-2.4.48”
[root@localhost httpd-2.4.48]# make install
等待编译完成
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: 离开目录“/bianyi/httpd-2.4.48”
[root@localhost bin]# /usr/local/apache/bin/apachectl
#启动服务
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 bin]# netstat -ntap |grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      56463/httpd 
[root@localhost bin]# systemctl stop firewalld.service 
[root@localhost bin]# setenforce 0
[root@localhost bin]# netstat -ntap |grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      56463/httpd

[root@localhost ~]# ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.91.101  netmask 255.255.255.0  broadcast 192.168.91.255
        inet6 fe80::eca:d785:4cb4:decc  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:4a:d7:ad  txqueuelen 1000  (Ethernet)
        RX packets 15430  bytes 1316891 (1.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8211  bytes 1251916 (1.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

第四周任务

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

[root@localhost ~]#ifconfig ens33 | sed -n '/inet /s#\(.*inet \)\(.*\)\( n.*\)#\2#'
192.168.91.101 

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

[root@localhost ~]# sed -i.bak '/^# */d;/^$/d' /etc/fstab
[root@localhost ~]# cat /etc/fstab
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=7ec76051-e030-4736-9bff-ac3d9e496fef /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0

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

[root@localhost ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\1#'
etc
[root@localhost ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\2#'
fstab

6、列出ubuntu软件管理工具apt的一些用法(*总结)

不会

ab路径,使用sed命令取出其目录名和基名

[root@localhost ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\1#'
etc
[root@localhost ~]# echo "/etc/fstab" |sed -r 's#^/(.*)/(.*)#\2#'
fstab

6、列出ubuntu软件管理工具apt的一些用法(*总结)

不会
上一篇:PHP 根据时间差得出时分秒


下一篇:aiohttp