2.2.5更新源至国内源
cd /etc/yum.repos.d
备份源文件
cp -r ./ ../yum.repos.d.bak
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
若wget未安装,则使用 yum install -y wget安装 或者使用curl 更新命令
curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo
接着使用 yum clean all 清空缓存
yum makecache更新yum缓存
2.2.6 安装扩展源epel
yum install -y epel-release
yum makecache更新yum缓存
3.yum 下载rpm包
仅下载不安装未安装过的包:yum install -y 包名 --downloadonly
下载安装过的包: yum reinstall -y 包名 --downloadonly
默认存储位置:/var/cache/yum/x86_64/7/仓库名/packages
使用该参数可以指定下载的包存放位置:--donwloaddir=/tmp/(例如存放在tmp下)
4.源码包编译安装软件(这里演示安装apache的http服务,主要提供安装思路。)
4.1源码存放:
cd /usr/local/src/
4.2 去apache的官网(http://httpd.apache.org/download.cgi)下载源码(有bz2h和gz两种格式,这里我用的是gz)
wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
tar zxvf httpd-2.4.29.tar.gz
cd httpd-2.4.29
一般源文件都带有README文件。这里也不例外
more README
其中Installation内容指出查看INSTASLL.
我们再接着查看 INSTASLL 文件
这里指出了安装文档的路径,和简单安装的方法,我们按简单的安装先进行。
指定安装的路径使用参数--prefix
./configure --prefix=/usr/local/apache2
这里显示APR未安装,查阅刚刚出现过的官方文档显示
APR and APR-Util Make sure you have APR and APR-Util already installed on your system. If you don't, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from Apache APR, unpack them into install the corresponding |
由于我们是精简安装的操作系统,所以没有内置APR和APR-Util所以需下载到指定的目录,并且配置configure的时候需要指定apr路径。
cd /srclib
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz
wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar zxvf apr-1.6.3.tar.gz
mv mv apr-1.6.3 apr
tar zxvf apr-util-1.6.1.tar.gz
mv apr-util-1.6.1 apr-util
此时cd ..
./configure --prefix=/usr/local/apache2 --with-include-apr=./srclib/apr --with-inclde-apr-util=./srclib/apr-util
提示gcc未安装,我们再进行gcc的安装
yum install -y gcc
安装完后,再次执行
./configure --prefix=/usr/local/apache2 --with-include-apr=./srclib/apr --with-inclde-apr-util=./srclib/apr-util
此时错误信息已变为另外一个。
Perl-Compatible Regular Expressions Library (PCRE) This library is required but not longer bundled with httpd. Download the source code from http://www.pcre.org, or install a Port or Package. If your build system can't find the pcre-config script installed by the PCRE build, point to it using the |
查询对应的软件包:
yum search PCRE
尝试安装 pcre-devel
yum install pcre-devel
继续配置
./configure --prefix=/usr/local/apache2 --with-include-apr=./srclib/apr --with-inclde-apr-util=./srclib/apr-util
配置成功(生成makefile文件)。
此时我们开始编译。
make
编译错误。
提示找不到expat.h这个头文件。
find ./ -name expat.h
发现这个文件不存在
通过搜索引擎查找这个头文件,发现缺少依赖expat-devel,安装依赖
yum install expat-devel
继续编译
make
编译成功
着重讲下echo $?
当返回值非0时,表示上一条命令执行不成。
返回值为0时,表示上一条命令执行成功。
接着我们进行安装
make install
安装成功
cd /usr/local/apache2/
修改配置当,尝试启动
vim /usr/local/apache2/conf/httpd.conf
/usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.conf
若要删除httpd服务器,只需
rm-rf /usr/local/apach2