[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
[root@localhost yum.repos.d]# rm -f CentOS-Base.repo
[root@localhost yum.repos.d]#
因为刚刚把yum源删掉了,wget没有安装,无法yum安装所以使用curl来进行添加。
[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 7271 0 --:--:-- --:--:-- --:--:-- 7311
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
[root@localhost yum.repos.d]#
之后可以安装一个rpm包试一下
[root@localhost yum.repos.d]# yum install -y wget
已加载插件:fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Determining fastest mirrors
正在解决依赖关系
--> 正在检查事务
---> 软件包 wget.x86_64.0.1.14-13.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================================
正在安装:
wget x86_64 1.14-13.el7 base 546 k
事务概要
====================================================================================================================================================
安装 1 软件包
总下载量:546 k
安装大小:2.0 M
Downloading packages:
wget-1.14-13.el7.x86_64.rpm | 546 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : wget-1.14-13.el7.x86_64 1/1
验证中 : wget-1.14-13.el7.x86_64 1/1
已安装:
wget.x86_64 0:1.14-13.el7
完毕!
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
[root@localhost yum.repos.d]# yum install -y epel-release
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-9 将被 安装
--> 解决依赖关系完成
完毕!
[root@localhost yum.repos.d]# ls
CentOS7-Base-163.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel-testing.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo
[root@localhost yum.repos.d]#
多了两个安装源
[root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/updates/packages/
zsh-5.0.2-25.el7_3.1.x86_64.rpm
[root@localhost yum.repos.d]# yum install zsh --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.neusoft.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 zsh.x86_64.0.5.0.2-25.el7_3.1 将被 安装
--> 解决依赖关系完成
[root@localhost yum.repos.d]# ls /tmp/
1.txt
1.txt.gz
zsh-5.0.2-25.el7_3.1.x86_64.rpm
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# yum install vim-enhanced --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: ftp.jaist.ac.jp
软件包 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost yum.repos.d]# yum reinstall vim-enhanced --downloadonly --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.tuna.tsinghua.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 vim-enhanced.x86_64.2.7.4.160-1.el7_3.1 将被 已重新安装
--> 解决依赖关系完成
约定:以后源码包下载好后放到cd /usr/local/src/下
[root@localhost yum.repos.d]# cd /usr/local/src/
[root@localhost src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
--2017-08-29 22:37:00-- http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz
正在解析主机 mirrors.cnnic.cn (mirrors.cnnic.cn)... 101.6.6.178, 2402:f000:1:416:101:6:6:177
正在连接 mirrors.cnnic.cn (mirrors.cnnic.cn)|101.6.6.178|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:http://219.239.26.14/files/5162000009CC51A1/mirror.bit.edu.cn/apache//httpd/httpd-2.2.32.tar.gz [跟随至新的 URL]
--2017-08-29 22:37:00-- http://219.239.26.14/files/5162000009CC51A1/mirror.bit.edu.cn/apache//httpd/httpd-2.2.32.tar.gz
正在连接 219.239.26.14:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:7684420 (7.3M) [application/octet-stream]
正在保存至: “httpd-2.2.32.tar.gz”
100%[==========================================================================================================>] 7,684,420 1.43MB/s 用时 5.1s
2017-08-29 22:37:06 (1.43 MB/s) - 已保存 “httpd-2.2.32.tar.gz” [7684420/7684420])
[root@localhost src]# ls
httpd-2.2.32.tar.gz
[root@localhost src]# ls
httpd-2.2.32 httpd-2.2.32.tar.gz
[root@localhost src]# cd httpd-2.2.32
[root@localhost httpd-2.2.32]# ls
ABOUT_APACHE BuildAll.dsp config.layout emacs-style httpd.spec LAYOUT LICENSE NOTICE README.platforms srclib
acinclude.m4 BuildBin.dsp configure httpd.dep include libhttpd.dep Makefile.in NWGNUmakefile README-win32.txt support
Apache.dsw buildconf configure.in httpd.dsp INSTALL libhttpd.dsp Makefile.win os ROADMAP test
build CHANGES docs httpd.mak InstallBin.dsp libhttpd.mak modules README server VERSIONING
[root@localhost httpd-2.2.32]#
For complete installation documentation, see [ht]docs/manual/install.html or
http://httpd.apache.org/docs/2.2/install.html
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
[root@localhost httpd-2.2.32]# ./configure --prefix=/usr/local/apache2
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.2
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.32/srclib/apr‘:
configure: error: no acceptable C compiler found in $PATH
See `config.log‘ for more details
configure failed for srclib/apr
[root@localhost httpd-2.2.32]#
这条命令执行是有报错的。查看上一条命令执行的有没有报错输入“echo $?”。输出结果不是0说明有报错
报错说明gcc不存在,这样的话yum安装一下,yum install gcc
[root@localhost httpd-2.2.32]# echo $?
0
安装完之后检测echo $? 是0 ,说明没有问题
大概等两分钟的样子之后完成,然后查看有没有错误
[root@localhost httpd-2.2.32]# echo $?
0
这条命令是安装编译好的文件
查看目录下都安装了什么
[root@localhost httpd-2.2.32]# ls /usr/local/apache2/ bin build cgi-bin conf error htdocs icons include lib logs man manual modules [root@localhost httpd-2.2.32]#
- ### 卸载就是删除安装的文件
- ### 下载源码包一定要注意安全,去官方或者可信任站点下载
# 扩展
1. 配置yum源优先级 http://ask.apelearn.com/question/7168
2. 把源码包打包成rpm包 http://www.linuxidc.com/Linux/2012-09/70096.htm
原文地址:http://blog.51cto.com/11751505/2105637