linux学习lesson22

目录

1 yum更换国内源

2 yum下载rpm包

3 源码包安装


1 yum更换国内源

[root@worker1 ~]# cd /etc/yum.repos.d
[root@worker1 yum.repos.d]# rm -f dvd.repo
法1:
[root@worker1 yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
--2018-10-10 00:43:21--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 157.255.28.135, 157.255.28.136, 157.255.28.227, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|157.255.28.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-7.repo’

100%[===================================================>] 2,523       --.-K/s   in 0s      

2018-10-10 00:43:21 (134 MB/s) - ‘Centos-7.repo’ saved [2523/2523]

[root@worker1 yum.repos.d]# ls
Centos-7.repo
法2:
[root@worker1 yum.repos.d]# curl -O http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  17467      0 --:--:-- --:--:-- --:--:-- 17520
[root@worker1 yum.repos.d]# ls
Centos-7.repo
[root@worker1 yum.repos.d]# yum list |tail -20
yum-plugin-upgrade-helper.noarch            1.1.31-46.el7_5            updates  
yum-plugin-verify.noarch                    1.1.31-46.el7_5            updates  
yum-plugin-versionlock.noarch               1.1.31-46.el7_5            updates  
yum-rhn-plugin.noarch                       2.0.1-10.el7               base     
yum-updateonboot.noarch                     1.1.31-46.el7_5            updates  
yum-utils.noarch                            1.1.31-46.el7_5            updates  
zenity.x86_64                               3.22.0-1.el7               base     
zlib.i686                                   1.2.7-17.el7               base     
zlib.x86_64                                 1.2.7-17.el7               base     
zlib-devel.i686                             1.2.7-17.el7               base     
zlib-devel.x86_64                           1.2.7-17.el7               base     
zlib-static.i686                            1.2.7-17.el7               base     
zlib-static.x86_64                          1.2.7-17.el7               base     
zsh.x86_64                                  5.0.2-28.el7               base     
zsh-html.x86_64                             5.0.2-28.el7               base     
zziplib.i686                                0.13.62-5.el7              base     
zziplib.x86_64                              0.13.62-5.el7              base     
zziplib-devel.i686                          0.13.62-5.el7              base     
zziplib-devel.x86_64                        0.13.62-5.el7              base     
zziplib-utils.x86_64                        0.13.62-5.el7              base   

 

2 yum下载rpm包

  • 安装扩展源
[root@worker1 yum.repos.d]# yum install -y epel-release
Loaded plugins: fastestmirror
base                                                                  | 3.6 kB  00:00:00     
extras                                                                | 3.4 kB  00:00:00     
updates                                                               | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================
Package                   Arch                Version             Repository           Size
=============================================================================================
Installing:
epel-release              noarch              7-11                extras               15 k

Transaction Summary
=============================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 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
  Installing : epel-release-7-11.noarch                                                  1/1
  Verifying  : epel-release-7-11.noarch                                                  1/1

Installed:
  epel-release.noarch 0:7-11                                                                 

Complete!
[root@worker1 yum.repos.d]# yum list | grep epel | head
* epel: mirrors.aliyun.com
epel-release.noarch                      7-11                          @extras  
0ad.x86_64                               0.0.22-1.el7                  epel     
0ad-data.noarch                          0.0.22-1.el7                  epel     
0install.x86_64                          2.11-1.el7                    epel     
2048-cli.x86_64                          0.9.1-1.el7                   epel     
2048-cli-nocurses.x86_64                 0.9.1-1.el7                   epel     
2ping.noarch                             3.2.1-2.el7                   epel     
389-admin.x86_64                         1.1.46-1.el7                  epel     
389-admin-console.noarch                 1.1.12-1.el7                  epel     


Exiting on Broken Pipe
  • 下载rpm包

yum install -y 包名 --downloadonly 下载默认的路径(后面跟仓库名,ls /var/cache/yum/x86_64/7/)

yum install -y 包名 --downloadonly 下载默认的路径(后面跟仓库名,ls /var/cache/yum/x86_64/7/)
[root@worker1 packages]# yum install -y zsh --downloadonly
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-14.el7 will be updated
---> Package zsh.x86_64 0:5.0.2-28.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================
Package           Arch                 Version                     Repository          Size
=============================================================================================
Updating:
zsh               x86_64               5.0.2-28.el7                base               2.4 M

Transaction Summary
=============================================================================================
Upgrade  1 Package

Total download size: 2.4 M
Background downloading packages, then exiting:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
zsh-5.0.2-28.el7.x86_64.rpm                                           | 2.4 MB  00:00:00     
exiting because "Download Only" specified
[root@worker1 packages]# ls /var/cache/yum/x86_64/7/base/packages/
zsh-5.0.2-28.el7.x86_64.rpm
  • 下载没安装的包,并指定路径

yum install -y 包名 --downloadonly --downloaddir=路径

[root@worker1 packages]# yum install -y zsh --downloadonly --downloaddir=/tmp/
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror.lzu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package zsh.x86_64 0:5.0.2-14.el7 will be updated
---> Package zsh.x86_64 0:5.0.2-28.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================
Package           Arch                 Version                     Repository          Size
=============================================================================================
Updating:
zsh               x86_64               5.0.2-28.el7                base               2.4 M

Transaction Summary
=============================================================================================
Upgrade  1 Package

Total download size: 2.4 M
Background downloading packages, then exiting:
exiting because "Download Only" specified
[root@worker1 packages]# ls /tmp/
dir123         yum_save_tx.2018-10-10.00-54.CkX7yH.yumtx
test.txt.new   yum_save_tx.2018-10-10.00-57.gQnNpa.yumtx
test.txt.new2  zsh-5.0.2-28.el7.x86_64.rpm
  • 下载已经安装的包,并指定路径

yum reinstall -y 包名 --downloadonly --downloaddir=路径

[root@worker1 packages]# yum reinstall -y vim-enhanced --downloadonly --downloaddir=/tmp/
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.160-4.el7 will be reinstalled
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================
Package                 Arch              Version                     Repository       Size
=============================================================================================
Reinstalling:
vim-enhanced            x86_64            2:7.4.160-4.el7             base            1.0 M

Transaction Summary
=============================================================================================
Reinstall  1 Package

Total download size: 1.0 M
Installed size: 2.2 M
Background downloading packages, then exiting:
vim-enhanced-7.4.160-4.el7.x86_64.rpm                                 | 1.0 MB  00:00:00     
exiting because "Download Only" specified

 

3 源码包安装

  • 下载httpd-2.2
[root@worker1 packages]# cd /usr/local/src/
[root@worker1 src]# wget https://cfhcable.dl.sourceforge.net/project/apachehttpserver/httpd-2.2.27.tar.gz
--2018-10-10 01:00:23--  https://cfhcable.dl.sourceforge.net/project/apachehttpserver/httpd-2.2.27.tar.gz
Resolving cfhcable.dl.sourceforge.net (cfhcable.dl.sourceforge.net)... 146.71.73.6
Connecting to cfhcable.dl.sourceforge.net (cfhcable.dl.sourceforge.net)|146.71.73.6|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8350426 (8.0M) [application/x-gzip]
Saving to: ‘httpd-2.2.27.tar.gz’

100%[===================================================>] 8,350,426    245KB/s   in 33s    

2018-10-10 01:00:57 (247 KB/s) - ‘httpd-2.2.27.tar.gz’ saved [8350426/8350426]

[root@worker1 src]# ls
apr-1.6.3.tar.gz       mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz  php-5.6.32.tar.bz2
apr-util-1.6.1.tar.gz  master.zip                                    php-7.1.6.tar.bz2
httpd-2.2.27.tar.gz    memcached-1.4.30.tar.gz                       phpredis-develop.zip
httpd-2.4.34.tar.gz    mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz    redis-2.8.21.tar.gz
iTop-2.3.4-3302.zip    nginx-1.10.3.tar.gz
  • 解压httpd-2.2.27.tar.gz
[root@worker1 src]# tar -zxvf httpd-2.2.27.tar.gz
[root@worker1 src]# cd httpd-2.2.27
  • 配置编译
[root@worker1 httpd-2.2.27]# ./configure --prefix=/usr/local/apache2.2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu

Configuring Apache Portable Runtime library ...

checking for APR... reconfig
configuring package in srclib/apr now
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.0
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/httpd-2.2.27/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
configure failed for srclib/apr

原因是没有安装gcc

[root@worker1 httpd-2.2.27]# yum install -y gcc
  • 再次配置文件
[root@worker1 httpd-2.2.27]# ./configure --prefix=/usr/local/apache2.2
  • 检查是否正确安装
[root@worker1 httpd-2.2.27]# echo $?

0
  • 执行make
[root@worker1 httpd-2.2.27]# make
[root@worker1 httpd-2.2.27]# echo $?
0
  • 执行make install
[root@worker1 httpd-2.2.27]# make install
[root@worker1 httpd-2.2.27]# echo $?
0
[root@worker1 httpd-2.2.27]# ls /usr/local/apache2.2/
bin  build  cgi-bin  conf  error  htdocs  icons  include  lib  logs  man  manual  modules
  • 卸载源码安装
[root@worker1 httpd-2.2.27]# rm -rf  /usr/local/apache2.2/

 

扩展
1. 把源码包打包成rpm包 https://jin-yang.github.io/post/linux-create-rpm-package.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值