第四周:私有库和编译安装

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

1)仓库服务器配置

[root@centos8 ~]#yum -y install httpd

[root@centos8 ~]#systemctl enable --now httpd

[root@centos8 ~]#mkdir /var/www/html/centos/8 -pv

[root@centos8 ~]#mount /dev/sr1 /var/www/html/cenos/8

2)yum客户端配置

[root@centos8 ~]#vim /etc/yum.repos.d/test.repo

[BaseOS]

name=BaseOS

baseurl=http://192.168.203.132/centos/8/BaseOS

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosoffical

[AppStream]

name=AppStream

baseurl=http://192.168.203.132/centos/8/AppStream

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosoffical

#下载相关仓库包和元数据

[root@centos8 ~]#dnf reposync --repoid=epel --download-metadata-p /var/www/html

#下载相关的key文件

[root@repo-server ~]#wget -P /var/www/html/epel/ http://mirrors.aliyun.com/epel.RPM-GPG-KEY-EPEL-8

[root@centos8 ~]#ls /var/www/html/epel/

Packages repodata

[root@centos8 ~]#systemctl start httpd

[root@centos8 ~]#cat /etc/yum.repos.d/test.repo

[BaseOS]

name=BaseOS

baseurl=http://192.168.203.132/centos/8/BaseOS

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosoffical


[AppStream]

name=AppStream

baseurl=http://192.168.203.132/centos/8/AppStream/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosoffical


[epel]

name=epel

baseurl=http://192.168.203.132/epel/

gpgcheck=1

gpgkey=http:// 192.168.203.132/epel/RPM-GPG-KEY-EPEL-8

[root@centos8 ~]#yum repolist

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

#安装前准备:关闭防火墙和SELinux

#1 安装相关包

[root@centos8 ~]#dnf install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config

#2 下载并解压缩包

[root@centos8~]#wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2

[root@centos8 ~]#tar xvf httpd-2.4.46.tar.bz2 -C /usr/local/src

#3 配置

[root@centos8 ~]#cd /usr/local/src/httpd-2.4.46/

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

#4 编译并安装

[root@centos8 httpd-2.4.46]#make -j 2 && make install

#5 配置环境

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

[root@centos8 ~]#. /etc/profile.d/httpd.sh

#6 运行

[root@centos8 ~]#apachectl start

#7 指定用apache用户运行

[root@centos8 ~]#useradd -r -g apache -s /sbin/nologin -d /var/www -c Apache -u 48 apache

[root@centos8 ~]#vim /etc/httpd/httpd.conf

#8 配置生效和验证

[root@centos8 ~]#apachectl restart

#9 查看进程

[root@centos8 ~]#ps aux

#10 用浏览器打开以下地址,看页面It works即可

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

ifconfig | sed -nr '2s@^[^0-9]+([0-9.]+).*@\1@p' 

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

 sed -nr 's@^#[[:space:]]+(.*)@\1@p' /etc/fstab

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

echo /etc/fstab | sed -nr 's@^ (.*)/([^/]+)@\1@p' 

echo /etc/fstab | sed -nr 's@^ (.*)/([^/]+)@\2@p' 

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

apt install  安装软件包

apt remove   删除软件包

apt purge   移除软件包及配置文件

apt update  刷新存储库索引

apt upgrade  升级所有可升级的软件包

apt autoremove  自动删除不需要的包

apt full-upgrade  在升级软件包时自动处理依赖关系

apt search  搜索应用程序

apt show  显示安装细节

apt特有的命令

apt list   列出包含条件的包(已安装,可升级等)

apt edit-sources   编辑源列表

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1、查找/var目录下不属于root、lp、gdm的所有文件 find /var! \( -user root -...
    hl大宝阅读 214评论 0 0
  • 1、打包/etc/目录下面所有conf结尾的文件,压缩包名称为当天的时间,并拷贝到/usr/local/src目录...
    记忆终泛白阅读 196评论 0 0
  • 1、每12小时备份并压缩/etc/目录至/backup目录中,保存文件名称格式为,"etc-年-月-日-时-分.t...
    是小何同学阅读 705评论 0 0
  • 1、自建yum仓库,分别为网络源和本地源网络源yum仓库:Linux版本:Centos7网络yum源:阿里云[ro...
    网络小孩阅读 241评论 1 0
  • 1、自建yum仓库,分别为网络源和本地源 配置光盘自动挂载rpm -q autofs || yum -y inst...
    铛铃叮阅读 186评论 0 0

友情链接更多精彩内容