Linux学习
一、yum更换国内源
二、yum下载rpm包
三、源码包安装
一、yum更换国内源
操作
[root@localhost yum.repos.d]# cat CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# rm -f CentOS-Base.repo
[root@localhost yum.repos.d]# ls
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# yum install -y wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
-bash: wget: 未找到命令
[root@localhost yum.repos.d]# curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1572 100 1572 0 0 484 0 0:00:03 0:00:03 --:--:-- 484
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@localhost yum.repos.d]#
二、yum下载rpm包
- 安装扩展源epel
- yum install -y epel-release
- yum list |grep epel
操作
[root@localhost yum.repos.d]# yum install -y epel-release
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成
依赖关系解决
=====================================================================================================================
Package 架构 版本 源 大小
=====================================================================================================================
正在安装:
epel-release noarch 7-11 extras 15 k
事务概要
=====================================================================================================================
安装 1 软件包
总下载量:15 k
安装大小:24 k
Downloading packages:
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : epel-release-7-11.noarch 1/1
验证中 : epel-release-7-11.noarch 1/1
已安装:
epel-release.noarch 0:7-11
完毕!
[root@localhost yum.repos.d]#
- 使用yum下载rpm包
- yum install -y包名 --downloadonly
- ls /var/cache/yum/x86_64/7/
- yum install -y 包名 --downloadonly --downloaddir=路径
- yum reinstall -y 包名 --downloadonly --downloaddir=路径
操作
[root@localhost ~]# yum install zsh --downloadonly
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 zsh.x86_64.0.5.0.2-28.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=====================================================================================================================
Package 架构 版本 源 大小
=====================================================================================================================
正在安装:
zsh x86_64 5.0.2-28.el7 base 2.4 M
事务概要
=====================================================================================================================
安装 1 软件包
总下载量:2.4 M
安装大小:5.6 M
Background downloading packages, then exiting:
zsh-5.0.2-28.el7.x86_64.rpm | 2.4 MB 00:00:04
exiting because "Download Only" specified
[root@localhost ~]#
下载的rpm包存放在这个路径下
[root@localhost ~]# ls /var/cache/yum/x86_64/7/
base epel extras timedhosts timedhosts.txt updates
[root@localhost ~]#
指定下载路径
[root@localhost ~]# ls /tmp/
fping-3.10-4.el7.x86_64.rpm
ks-script-vh6hrP
net-snmp-libs-5.7.2-33.el7_5.2.x86_64.rpm
OpenIPMI-libs-2.0.23-2.el7.x86_64.rpm
OpenIPMI-modalias-2.0.23-2.el7.x86_64.rpm
systemd-private-76be1cb3392f4bd79f624cd4af8c506c-chronyd.service-tbhOs2
traceroute-2.0.22-2.el7.x86_64.rpm
unixODBC-2.3.1-11.el7.x86_64.rpm
vmware-root
yum.log
yum_save_tx.2018-10-14.21-16.3B4A2d.yumtx
yum_save_tx.2018-10-14.21-21.Q6gLLh.yumtx
zabbix22-2.2.23-1.el7.x86_64.rpm
zabbix22-dbfiles-mysql-2.2.23-1.el7.noarch.rpm
zabbix22-server-2.2.23-1.el7.noarch.rpm
zabbix22-server-mysql-2.2.23-1.el7.x86_64.rpm
[root@localhost ~]#
如果已经安装的包,只下载则提示无须任何处理,无法下载
[root@localhost ~]# yum install vim-enhanced --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.aliyun.com
软件包 2:vim-enhanced-7.4.160-4.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]#
使用yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
[root@localhost ~]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.yun-idc.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 vim-enhanced.x86_64.2.7.4.160-4.el7 将被 已重新安装
--> 解决依赖关系完成
依赖关系解决
=====================================================================================================================
Package 架构 版本 源 大小
=====================================================================================================================
重新安装:
vim-enhanced x86_64 2:7.4.160-4.el7 base 1.0 M
事务概要
=====================================================================================================================
重新安装 1 软件包
总计:1.0 M
安装大小:2.2 M
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@localhost ~]#
三、源码包安装
操作
[root@localhost ~]# wget https://mirrors.cnnic.cn/apache/httpd/httpd-2.4.35.tar.gz
--2018-10-14 21:36:35-- https://mirrors.cnnic.cn/apache/httpd/httpd-2.4.35.tar.gz
正在解析主机 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9167147 (8.7M) [application/x-gzip]
正在保存至: “httpd-2.4.35.tar.gz”
100% [===========================================================================>] 9,167,147 592KB/s 用时 15s
2018-10-14 21:36:50 (617 KB/s) - 已保存 “httpd-2.4.35.tar.gz” [9167147/9167147])
[root@localhost ~]#
[root@localhost ~]# ls
anaconda-ks.cfg httpd-2.4.35.tar.gz
[root@localhost ~]# mv httpd-2.4.35.tar.gz /usr/local/src/
[root@localhost ~]# ls
anaconda-ks.cfg
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ls
httpd-2.4.35.tar.gz
[root@localhost src]#
[root@localhost src]# tar -zxvf httpd-2.4.35.tar.gz
[root@localhost src]# ls
httpd-2.4.35 httpd-2.4.35.tar.gz
[root@localhost src]# cd httpd-2.4.35
[root@localhost httpd-2.4.35]# ls
ABOUT_APACHE BuildAll.dsp configure.in include LICENSE README test
acinclude.m4 BuildBin.dsp docs INSTALL Makefile.in README.cmake VERSIONING
Apache-apr2.dsw buildconf emacs-style InstallBin.dsp Makefile.win README.platforms
Apache.dsw CHANGES httpd.dep LAYOUT modules ROADMAP
apache_probes.d CMakeLists.txt httpd.dsp libhttpd.dep NOTICE server
ap.d config.layout httpd.mak libhttpd.dsp NWGNUmakefile srclib
build configure httpd.spec libhttpd.mak os support
[root@localhost httpd-2.4.35]#
- 查看README和INSTALL文档
- 编译安装
- 使用echo $?返回值非0是指上一条命令报错,此命令用于检测上一条命令是否正确
- make install 命令会把编译后的文档放置在--prefix下指定的目录里
- 源码包安装可以指定目录,把所有文件都放在一个目录下,如果需要卸载,直接删除该目录即可。
- 源码包下载一定要具备可靠性、安全性。
编译安装
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --disable-proxy
[root@localhost httpd-2.4.35]make && make install
[root@localhost httpd-2.4.35]# echo $?
0
[root@localhost httpd-2.4.35]#
[root@localhost src]# cd ..
[root@localhost local]# ls
apache apr apr-util bin etc games include lib lib64 libexec pcre sbin share src
[root@localhost local]# cd apache/
[root@localhost apache]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@localhost apache]#