第六周作业

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

#备份yum旧文件
mkdir -p /etc/yum.repos.d/backup
mv /etc/yum.d/*.repo bakcup/
cat >/etc/yum.repos.d/base.repo <<EOF
[BaseOS]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        file:///mnt/BaseOS/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStram]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
        file:///mnt/AppStream/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[EPEL]
name=Centos-$releasever - EPEL
baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-8
enabled=1
EOF

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

#安装依赖包
[root@centos8 ~]#dnf install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
#下载源代码
[root@centos8 ~]#wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.gz
#解压目录
[root@centos8 ~]#tar zxvf httpd-2.4.46.tar.gz -C /usr/local/src
[root@centos8 ~]#cd /usr/local/src/httpd-2.4.46
#配置参数
[root@centos8 ~]#./configure --prefix=/apps/httpd24 --sysconfdir=/etc/httpd24 --enable-ssl
#编译并安装
[root@centos8 ~]#make -j 2 &&make install
#配置环境变量
[root@centos8 ~]#echo 'PATH=/apps/httpd24/bin:$PATH' > /etc/profile.d/httpd24.sh
[root@centos8 ~]#source /etc/profile.d/httpd24.sh
#创建apache用户
[root@centos8 ~]#useradd -r -u 48 -s /sbin/nologin -d /var/www apache 
#配置http配置文件,修改用户为apache
[root@centos8 ~]#vim /etc/httpd24/httpd.conf
User apache
Group apache
#启动服务
[root@centos8 ~]#apachectl start
#测试
[root@centos8 ~]# ps -aux |grep httpd
root       18705  0.0  0.2 117504  5216 ?        Ss   21:50   0:00 /apps/httpd24/bin/httpd -k start
apache     18709  0.4  0.4 2057880 7600 ?        Sl   21:50   0:00 /apps/httpd24/bin/httpd -k start
apache     18710  0.3  0.6 2123416 11680 ?       Sl   21:50   0:00 /apps/httpd24/bin/httpd -k start
apache     18711  0.0  0.4 2057880 7600 ?        Sl   21:50   0:00 /apps/httpd24/bin/httpd -k start
root       18804  0.0  0.0  12112  1088 pts/1    R+   21:51   0:00 grep --color=auto httpd
[root@centos8 ~]# ss -ntl
State                     Recv-Q                    Send-Q                                       Local Address:Port                                       Peer Address:Port                    
LISTEN                    0                         128                                                0.0.0.0:22                                              0.0.0.0:*                       
LISTEN                    0                         128                                                      *:80                                                    *:*                       
LISTEN                    0                         128                                                   [::]:22                                                 [::]:*                       
图片.png

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

ifconfig eth0 | sed -nr '/netmask/s#^[^0-9]+([0-9.]+).*$#\1#p'
ifconfig |awk 'NR==2{print $2}'

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

sed -i.bak '/^[#]/d' /etc/fstab

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

#目录名
echo /etc/fstab |sed -nr 's#(^.*\/)[a-z]+$#\1#p'
#基名
echo /etc/fstab |sed -nr 's#^.*\/([a-z]+)$#\1#p'
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、查找/etc目录下大于1M且类型为普通文件的所有文件 find /etc -size +1M -a -type...
    封心鎖愛_7b6b阅读 708评论 0 0
  • 1、查找/etc目录下大于1M且类型为普通文件的所有文件使用find /etc -type f -a size +...
    letsgoheat_c1dc阅读 825评论 0 0
  • 1、自建yum仓库,分别为网络源和本地源 1)基于本地光盘创建yum源 2)基于本地的网络yum源(web服务ht...
    196_fendou阅读 1,482评论 0 0
  • 第六周 1、自建yum仓库,分别为网络源和本地源 2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果...
    antikor阅读 2,481评论 1 0
  • 渐变的面目拼图要我怎么拼? 我是疲乏了还是投降了? 不是不允许自己坠落, 我没有滴水不进的保护膜。 就是害怕变得面...
    闷热当乘凉阅读 9,764评论 0 13