格式:
rpm {-i|--install} [install-options] PACKAGE_FILE...
选项:
-v: verbose
-vv:
-h: 以#显示程序包执行进度
--nodeps: 忽略依赖关系
#常用组合
rpm -ivh PACKAGE_FILE
rpm包升级
rpm {-U|--upgrade} [install-options] PACKAGE_FILE...
rpm {-F|--freshen} [install-options] PACKAGE_FILE...
--oldpackage: 降级
#常用组合
rpm -Uvh PACKAGE_FILE...
rpm -Fvh PACKAGE_FILE...
-U:安装有旧程序包,则升级,如果不存在旧程序包,则安装;
-F:安装有旧程序包,则升级,如果不存在旧程序包,则不执行升级操作
rpm {-q|--query} [select-options] [query-optinons]
[select-options]
-a: 所有包
-f: 查看指定的文件由哪个程序包安装生成
-p rpmfile: 针对未安装的程序包文件做查询
[query-options]
-c: 查询程序的配置文件
-d: 查询程序的文档
-i: 查询程序信息
-l: 查看指定的程序包安装后生成的所有文件
#常见用法
-qa PACKAGE
-qi PACKAGE
-qc PACKAGE
-ql PACKAGE
-qf PACKAGE
格式:
rpm {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--test] PACKAGE_FILE...
yum repolist [all|enabled|disabled]
yum install package1 [package2] [...]
yum reinstallpackage1 [package2] [...] #重新安装
yum remove | erase package1 [package2] [...]
yum update package1 [package2] [...] 升级
yum downgrade package1 [package2] [...] 降级
查看程序包信息:
yum info package1
查看指定的特性(某个文件)是由哪个程序包提供:
yum provides | whatprovides feature1 [feature2] [...]
注意:文件要写全路径,而不只是文件名,否则无法查询。
以指定的关键字搜索程序包及信息
yum search string1 [string2] [...]
清理目录/var/cache/yum/缓存
yum clean all
构建缓存
yum makecache
网络源:
[root@CentOS8 yum.repos.d]#mkdir backup
[root@CentOS8 yum.repos.d]#mv /etc/yum.repos.d/*.repo backup/
[root@CentOS8 yum.repos.d]#cat Netinstall.repo
[AppStream]
name=Netinstall AppStream
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[BaseOS]
name=Netinstall BaseOS
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8/BaseOS/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Extras] name=Netinstall Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8/extras/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Epel]
name=Netinstall Epel
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/8/Everything/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
本地源:
[root@CentOS8 yum.repos.d]#mount /dev/sr0 /media
[root@CentOS8 yum.repos.d]#cat local.repo
[BaseOS]
name=BaseOS
baseurl=file:///media/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[Appsteam]
name=Appsteam
baseurl=file:///media/AppStream
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
最小化安装的系统建议安装以下相关包
yum -y install gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree lsof tcpdump wget net-tools iotop bc bzip2 zip unzip nfs-utils man-pages
常用选项:
#安装路径设定
--prefix=/PATH 指定默认安装位置,默认为/usr/local
--sysconfdir=/PATH 配置文件安装位置
#安装依赖包
[root@CentOS8 local]#dnf install gcc make apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
#下载源码包
[root@CentOS8 src]#wget https://mirrors.bfsu.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
#解压源码包
[root@CentOS8 src]#tar xvf httpd-2.4.46.tar.bz2 -C /usr/local/src
#配置安装路径
[root@CentOS8 httpd-2.4.46]#cd/usr/local/src/httpd-2.4.46
[root@CentOS8 httpd-2.4.46]#./configure --prefix=/apps/httpd46 --sysconfdir=/etc/httpd46 --enable-ssl
onfig.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.46
Install prefix: /apps/httpd46
C compiler: gcc
CFLAGS: -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@CentOS8 httpd-2.4.46]#echo $?
0
#编译并安装
[root@CentOS8 httpd-2.4.46]#make -j 4
[root@CentOS8 httpd-2.4.46]#echo $?
0
[root@CentOS8 httpd-2.4.46]#make install
#启动服务
[root@CentOS8 httpd-2.4.46]#/apps/httpd46/bin/apachectl start
#指定用apache用户运行
[root@CentOS8 httpd-2.4.46]#useradd -r -s /sbin/nologin -d /var/www -c Apache -u 48 apache
[root@CentOS8 httpd-2.4.46]#vim /etc/httpd46/httpd.conf
user apache
group apache
#配置环境变量
[root@CentOS8 httpd-2.4.46]#echo ‘PATH=/apps/httpd46/bin:$PATH‘ > /etc/profile.d/httpd46.sh
[root@CentOS8 httpd-2.4.46]#. /etc/profile.d/httpd46.sh
#生效、验证
[root@CentOS8 httpd-2.4.46]#apachectl restart
[root@CentOS8 httpd-2.4.46]#ps aux| grep httpd
apache 18229 0.0 0.9 2110168 13692 ? Sl 21:01 0:00 /apps/httpd46/bin/httpd -k start
apache 18230 0.1 0.9 2110168 13692 ? Sl 21:01 0:00 /apps/httpd46/bin/httpd -k start
apache 18231 0.0 0.9 2110168 13688 ? Sl 21:01 0:00 /apps/httpd46/bin/httpd -k start
[root@CentOS8 httpd-2.4.46]#curl http://10.0.0.8
<html><body><h1>Welcome to Apache!</h1></body></html>
[root@CentOS8 yum.repos.d]#ifconfig ens33 |sed -nr ‘2s/^[^0-9]+([0-9.]+).*$/\1/p‘
10.0.0.8
[root@CentOS8 yum.repos.d]#sed -i.bak ‘/^[#]/d‘ /etc/fstab
[root@CentOS8 yum.repos.d]#cat /etc/fstab
UUID=907244e6-ae0b-4e55-a0f3-d1e8bf76dd14 / xfs defaults 0 0
UUID=14eec576-4634-4313-8680-df44abdae04f /boot xfs defaults 0 0
UUID=cef59b88-244a-4151-927e-4f091bb6ad3f /data xfs defaults 0 0
UUID=a7e66d1a-4823-41e7-9628-a68e06ef71d4 none swap defaults 0 0
#目录名
[root@CentOS8 etc]#echo /etc/fstab | sed -nr ‘s#(.*)/([^/]+)/?#\1#p‘
/etc
#基名
[root@CentOS8 etc]#echo /etc/fstab | sed -nr ‘s#(.*)/([^/]+)/?#\2#p‘
fstab
原文:https://blog.51cto.com/13618052/2662247