关于centos的软件安装及软件源修改(二)

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

040300_wQx2_3772229.png

其中Installation内容指出查看INSTASLL.

我们再接着查看 INSTASLL 文件

040640_2yGe_3772229.png

这里指出了安装文档的路径,和简单安装的方法,我们按简单的安装先进行。

指定安装的路径使用参数--prefix

./configure --prefix=/usr/local/apache2

040919_7aEQ_3772229.png

这里显示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 /httpd_source_tree_root/srclib/apr and /httpd_source_tree_root/srclib/apr-util (be sure the directory names do not have version numbers; for example, the APR distribution must be under /httpd_source_tree_root/srclib/apr/) and use ./configure's --with-included-apr option. On some platforms, you may have to

install the corresponding -dev packages to allow httpd to build against your installed copy of APR and APR-Util.

由于我们是精简安装的操作系统,所以没有内置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

043144_9C57_3772229.png

此时cd ..

./configure --prefix=/usr/local/apache2 --with-include-apr=./srclib/apr --with-inclde-apr-util=./srclib/apr-util

043321_yaRY_3772229.png

提示gcc未安装,我们再进行gcc的安装

yum install -y gcc

安装完后,再次执行

./configure --prefix=/usr/local/apache2 --with-include-apr=./srclib/apr --with-inclde-apr-util=./srclib/apr-util

043521_euEm_3772229.png

此时错误信息已变为另外一个。

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 --with-pcre parameter. On some platforms, you may have to install the corresponding -dev package to allow httpd to build against your installed copy of PCRE.

查询对应的软件包:

yum search PCRE

043856_Vjeq_3772229.png

尝试安装 pcre-devel

yum install pcre-devel

继续配置

./configure --prefix=/usr/local/apache2 --with-include-apr=./srclib/apr --with-inclde-apr-util=./srclib/apr-util

 

044155_GeBF_3772229.png

配置成功(生成makefile文件)。

此时我们开始编译。

make

044341_utdV_3772229.png

编译错误。

提示找不到expat.h这个头文件。

find ./ -name expat.h

发现这个文件不存在

通过搜索引擎查找这个头文件,发现缺少依赖expat-devel,安装依赖

yum install expat-devel

继续编译

make

045610_559h_3772229.png

编译成功

着重讲下echo $?

当返回值非0时,表示上一条命令执行不成。

返回值为0时,表示上一条命令执行成功。

 

接着我们进行安装

make install

045949_hSGm_3772229.png

安装成功

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

转载于:https://my.oschina.net/u/3772229/blog/1632633

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值