11.软件包管理-案例分析

1.查询命令java来自于哪个rpm包

[root@localhost ~]#which java
/usr/bin/java
[root@localhost ~]#ls /usr/bin/java -l
lrwxrwxrwx. 1 root root 22 Aug 24 10:17 /usr/bin/java -> /etc/alternatives/java
[root@localhost ~]#ls /etc/alternatives/java -l
lrwxrwxrwx. 1 root root 73 Aug 24 10:17 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin/java
[root@localhost ~]#rpm -qf /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin/java
java-1.8.0-openjdk-headless-1.8.0.262.b10-0.el7_8.x86_64
[root@localhost ~]#rpm -qa |grep java
tzdata-java-2020a-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.262.b10-0.el7_8.x86_64
java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64

2.yum的配置和使用,包括yum仓库的创建

[root@localhost /etc/yum.repos.d]#yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                         repo name                                           status
base                                            base cdrom                                          10,070
repolist: 10,070
[root@localhost /etc/yum.repos.d]#cat yum.repo 
[base]
name=base cdrom
baseurl=file:///mnt/cdrom
gpgcheck=0

3.编写系统初始化脚本 reset.sh,包括别名,提示符颜色, yum仓库配置文件,安装tree,ftp,lftp,telnet等包

[root@localhost /data]#cat reset.sh 
#!/bin/bash
#********************************************************************
#Author: Kevin.Wen
#Revision: 1.0
#QQ: 2510905014
#Date: 2020-08-24
#FileName: reset.sh
#********************************************************************

#设置别名、命令提示符颜色和PATH
cat > /etc/profile.d/env.sh << EOF
export PS1='\[\e[1;31m\][\u@\h \w]\$\[\e[0m\]'
export PATH=/usr/local/apache/bin:$PATH
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias editnet='vim /etc/sysconfig/network-scripts/ifcfg-eth0'
alias editnet='vim /etc/sysconfig/network-scriptsifcfg-ens33'
EOF
source /etc/profile.d/env.sh

#设置vim
cat > ~/.vimrc << EOF
set ignorecase
set cursorline
set ts=4
set autoindent
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
 call setline(1,"#!/bin/bash")
 call setline(2,"#********************************************************************")
 call setline(3,"#Author: Kevin.Wen")
 call setline(4,"#Revision: 1.0")
 call setline(5,"#QQ: ")
 call setline(6,"#Date: ".strftime("%Y-%m-%d"))
 call setline(7,"#FileName: ".expand("%")) 
 call setline(8,"#********************************************************************")
 call setline(9,"")
endif
endfunc
autocmd BufNewFile * normal G
EOF
source ~/.vimrc

#配置yum仓库
mkdir -p /etc/yum.repos.d/bak
mv *.repo bak/
cat > /etc/yum.repos.d/env.repo << EOF
[base]
name=base cdrom
baseurl=file:///mnt/cdrom
gpgcheck=0
EOF

#安装常用包
rpm -q tree &> /dev/null && echo "tree已安装" || ( yum install tree -y &> /dev/null && echo "tree安装成功" || echo "tree安装失败")
rpm -q ftp &> /dev/null && echo "ftp已安装" || ( yum install ftp -y &> /dev/null && echo "ftp安装成功" || echo "ftp安装失败" )
rpm -q lftp &> /dev/null && echo "lftp已安装" || ( yum install lftp -y &> /dev/null && echo "lftp安装成功" || echo "lftp安装失败" )
rpm -q telnet &> /dev/null && echo "telnet已安装" || ( yum install telnet -y &> /dev/null && echo "telnet安装成功" || echo “telnet安装失败”)

echo "初始化完成!!"

4.在CentOS 7上编译安装 apache 2.4.25 源码包,并启动此服务

[root@localhost /data]#tar xvf httpd-2.4.25.tar.gz
[root@localhost /data/httpd-2.4.25]#yum -y install gcc apr-devel apr-util-devel pcre-devel openssl-devel 
[root@localhost /data/httpd-2.4.25]#./configure \
--prefix=/app/httpd24 \
--sysconfdir=/etc/httpd \
--enable-ssl \
--enable-so
[root@localhost /data/httpd-2.4.25]#make -j 4
[root@localhost /data/httpd-2.4.25]#make install
[root@localhost /data/httpd-2.4.25]vim /etc/profile.d/env.sh
#export PATH=/app/httpd24/bin:/usr/local/apache/bin:$PATH
[root@localhost /data/httpd-2.4.25]. /etc/profile.d/env.sh
[root@localhost /data/httpd-2.4.25]echo $PATH
/app/httpd24/bin:/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/apache/bin:/root/bin
[root@localhost /data/httpd-2.4.25]cd
[root@localhost ~]#apachectl start

posted @ 2020-08-24 14:25  人生值得  阅读(161)  评论(0编辑  收藏  举报