马哥教育N63期-第四周作业

马哥教育N63期-第四周作业,第1张

马哥教育N63期-第四周作业 1、自建yum仓库,分别为网络源和本地源

首先加载centos7,8的光驱sr1和 sr0

[root@localhost yum.repos.d]#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  100G  0 disk 
├─sda1   8:1    0   10G  0 part /boot
├─sda2   8:2    0   40G  0 part /
├─sda3   8:3    0   40G  0 part /data
├─sda4   8:4    0    1K  0 part 
└─sda5   8:5    0    2G  0 part [SWAP]
sr0     11:0    1  9.3G  0 rom  /misc/cd
sr1     11:1    1   10G  0 rom  

安装httpd并开启http服务。

[root@localhost yum.repos.d]#yum install httpd -y || systemctl enable --now httpd

创建本地yum源的目录

[root@localhost html]#mkdir -pv centos{7,8} 
mkdir: created directory 'centos7'
mkdir: created directory 'centos8'

将centos7的光驱挂载到centos7的文件夹

[root@localhost html]#mount /dev/sr1 /var/www/html/centos7
mount: /var/www/html/centos7: WARNING: device write-protected, mounted read-only.

将centos8的光驱挂载到centos8的文件夹

[root@localhost test]#mount /dev/sr0 /var/www/html/centos8

这样本地源就建好了。可以用浏览器测试一下。

网络源可以在/etc/yum.repos.d/base.repo配置文件中配置,这里用阿里云为例。

[epel]
name=EPEL
baseurl=http://mirrors.aliyun.com/epel/$releasever/Everything/$basearch
gpgcheck=0
enabled=1

[extras]
name=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os
gpgcheck=0

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

首先下载http2.4源码包,并解压到指定文件夹。

[root@localhost ~]# wget -F /usr/local/src http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz
/usr/local/src: Scheme missing.
--2022-01-16 19:04:13--  http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz
Resolving archive.apache.org (archive.apache.org)... 138.201.131.134, 2a01:4f8:172:2ec5::2
Connecting to archive.apache.org (archive.apache.org)|138.201.131.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8460433 (8.1M) [application/x-gzip]
Saving to: ‘httpd-2.4.25.tar.gz’
[root@localhost ~]# tar xf httpd-2.4.25.tar.gz -C /usr/local/src
[root@localhost ~]# ls /usr/local/src
httpd-2.4.25

安装编译工具及依赖包

[root@localhost ~]# yum -y install gcc make autoconf apr-devel apr-util-devel pcredevel openssl-devel redhat-rpm-config
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: ftp.sjtu.edu.cn
Package gcc-4.8.5-44.el7.x86_64 already installed and latest version

进入源码包目录,执行configure脚本,指定安装路径

[root@localhost ~]# cd /usr/local/src/httpd-2.4.25

[root@localhost httpd-2.4.25]# ./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd --enable-ssl

执行make编译

[root@localhost httpd-2.4.25]# make

执行安装

[root@localhost httpd-2.4.25]# make install

配置环境变量

[root@localhost httpd-2.4.25]# echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost httpd-2.4.25]# . /etc/profile.d/httpd.sh

启动程序

[root@localhost httpd-2.4.25]# apachectl start

创建apache用户

[root@localhost httpd-2.4.25]# useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache

修改/etc/httpd/httpd.conf配置文件中的用户名和组

[root@localhost httpd-2.4.25]# vim /etc/httpd/httpd.conf
user apache
group apache
配置和生效
[root@localhost ~]# apachectl restart


3、利用sed 取出ifconfig命令中本机的IPv4地址
[root@centos8 ~]#ifconfig ens33 |sed -rn '2s/.*inet ([0-9.]+) .*/1/p'
10.0.0.10

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
sed -r s@^#' '+@@g /etc/fstab
sed -r 's/^#[[:blank:]]+//'g /etc/fstab

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@localhost ~]#echo /etc/fstab |sed -rn 's@^(.*)/([^/]+)@1@p'
/etc
[root@localhost ~]#echo /etc/fstab |sed -rn 's@^(.*)/([^/]+)@2@p'
fstab
[root@localhost ~]#

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

#安装包: apt install tree zip #安装图形桌面 apt install ubuntu-desktop #删除包: apt remove tree zip #说明:apt remove中添加--purge选项会删除包配置文件,谨慎使用 #更新包索引,相当于yum clean all;yum makecache apt update   #升级包:要升级系统,请首先更新软件包索引,再升级 apt upgrade #apt列出仓库软件包,等于yum list apt list #搜索安装包 apt search nginx #查看某个安装包的详细信息 apt show apache2 #在线安装软件包 apt install apache2 #卸载单个软件包但是保留配置⽂件 apt remove apache2 #删除安装包并解决依赖关系 apt autoremove apache2 #更新本地软件包列表索引,修改了apt仓库后必须执⾏ apt update 范例: 查找存在的文件来自于哪个包 范例: 查找不存在的文件存在于哪个包 #卸载单个软件包删除配置⽂件 apt purge apache2 #升级所有已安装且可升级到新版本的软件包 apt upgrade #升级整个系统,必要时可以移除旧软件包。 apt full-upgrade #编辑source源⽂件 apt edit-sources #查看仓库中软件包有哪些版本可以安装 apt-cache madison nginx

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5704647.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存