第四周练习记录
第四周
1、自建yum仓库,分别为网络源和本地源
删掉原yum源
rm-rf /etc/yum.repos.d/*
挂载光盘下的centos7安装包
mount /dev/sr0 /mnt/
创建yum源
vim /etc/yum.repos.d/base.repo [base] name=base baseurl=file:///mnt/ https://mirrors.aliyun.com/centos/$releasever/os/$basearch/ https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/ https://repo.huaweicloud.com/centos/$releasever/os/$basearch/ https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ [epel] name=epel baseurl=https://mirrors.aliyun.com/epel/$releasever/x86_64/ https://mirrors.cloud.tencent.com/epel/$releasever/x86_64/ https://mirrors.huaweicloud.com/epel/$releasever/x86_64/ https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/x86_64/ gpgcheck=0 enabled=1 [extras] name=extras baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ gpgcheck=0
2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
最小化安装建议先安装相关包
yum install gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree tmux lsof tcpdump wget net-tools iotop bc bzip2 zip unzip nfs-utils man-pages
下载httpd-2.4.48.tar.bz2
tar -jxvf httpd-2.4.48.tar.bz2 cd httpd-2.4.48 ./configure
报错显示:configure: error: APR not found. Please read the documentation
下载并编译安装apr
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.bz2 cd apr-1.7.0 ; ./configure --prefix=/usr/local/apr make ; make install
继续安装httpd
cd /date/httpd-2.4.48 ;./configure #报错显示:configure: error: APR-util not found. Please read the documentation.
下载编译安装apr-util
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz #解压后进入执行
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr #make时报错: make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Leaving directory `/date/apr-util-1.6.1' make: *** [all-recursive] Error 1 #网上搜索后显示缺少了一个xml解析器yum 安装一个 expat-devel 包即可 yum -y install expat-devel
#继续编译安装apr-util make&&make install
成功后;切换到httpd继续编译安装httpd:
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ #需指明apr以及apr-util路径 #执行成功后 make && make install #成功最后显示 Installing configuration files mkdir /usr/local/httpd/conf mkdir /usr/local/httpd/conf/extra mkdir /usr/local/httpd/conf/original mkdir /usr/local/httpd/conf/original/extra Installing HTML documents mkdir /usr/local/httpd/htdocs Installing error documents mkdir /usr/local/httpd/error Installing icons mkdir /usr/local/httpd/icons mkdir /usr/local/httpd/logs Installing CGIs mkdir /usr/local/httpd/cgi-bin Installing header files mkdir /usr/local/httpd/include Installing build system files mkdir /usr/local/httpd/build Installing man pages and online manual mkdir /usr/local/httpd/man mkdir /usr/local/httpd/man/man1 mkdir /usr/local/httpd/man/man8 mkdir /usr/local/httpd/manual make[1]: Leaving directory `/date/httpd-2.4.48'
开启httpd
usr/local/httpd/bin/httpd -k start
浏览器输入本地ip地址后:
编译安装apache2.4.48成功
3、利用sed 取出ifconfig命令中本机的IPv4地址
ifconfig eth0 | sed -n '/inet /s#\(.*inet \)\(.*\)\( n.*\)#\2#gp'
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
sed -ri.bak '/^#/s/^#//' /etc/fstab
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
echo /etc/fstab | sed -rn 's#(.*)/([^/]+)/?#\2#p' #取基名 echo /etc/fstab/ | sed -rn 's#(.*)/([^/]+)/?#\1#p' #取目录名
6、列出ubuntu软件管理工具apt的一些用法(自由总结)
apt install 安装软件包
apt remove 移除软件包
apt purge 移除软件包以及卑职文件
apt update 刷新存储库索引
apt upgrade 升级所有可升级的软件包
apt autoremove 自动删除不需要的包
apt full-upgrade在升级软件包是自动处理依赖关系
apt search 搜索应用程序
apt show 显示安装细节
apt list 列出包含条件的包
apt edit-sources 编辑源列表