欢迎光临
我们一直在努力

CentOS 7上安装源码Apache包并启用该服务,含解决

                                        如何在CentOS 7上安装源码Apache包并启用该服务

       第1步:先从Apache官网下载最新的Apache包,然后通过WinSCP上传到远程的Centos 7上

并挂载VMware的 iso CentOS 7镜像后部署好本地的yum源—–

使VMware 12中的DVD自动挂载,添加如下语句到/etc/fstab

[root@Franklin13 ~]# cat /etc/fstab|grep cdrom

/dev/cdrom /media/cdrom auto defaults 0 0

——–编译安装过程如下 ————-

     第2步: 查看源码包里的INSTALL或readme文件并用yum命令查看Development Tools组合包是否已安装

(因./configure编译时要调用 Development Tools安装后的某个软件,比如GCC )

[root@Franklin13 httpd-2.4.41]# ls -l|grep IN*

-rw-r–r–.  1 root dip    3782 May 18  2016 INSTALL

有时,yum groupinstall “Development tools”会出现如下报错,且用yum clean all; yum makecache后仍旧出现这种报错

经Google后发现需要用如下方式安装才能进行:

yum groupinstall “Development Tools” –setopt=group_package_types=mandatory,default,optional

这种情况的原因很多,见如下网址

 https://access.redhat.com/solutions/1310043

第3步:进入解压后的httpd目录中,运行编译的3部曲 ./configure –prefix=…&make&make install:

但有时会出现报错,比如我遇到的 “ checking for APR… no ”

[root@Franklin13 httpd-2.4.41]# ./configure –prefix=/usr/local/apache2.4.41 –sysconfdir=/etc/httpd2

checking for chosen layout… Apache

checking for working mkdir -p… yes

checking for grep that handles long lines and -e… /usr/bin/grep

checking for egrep… /usr/bin/grep -E

checking build system type… x86_64-pc-linux-gnu

checking host system type… x86_64-pc-linux-gnu

checking target system type… x86_64-pc-linux-gnu

configure: 

configure: Configuring Apache Portable Runtime library…

configure: 

checking for APR… no

经百度后发现是如下原因: 

参考文章—- https://www.cnblogs.com/yewandemty/p/5396338.html

      先将这些模块(apr和apr-util 安装,再进行httpd的安装 )

Apr的下载网址: http://archive.apache.org/dist/

Apr-util的下载: http://archive.apache.org/dist/apr/

(注意:要先安装 apr,再安装 apr-uti,且安装apr-uti时要添加  –with-apr=后面跟之前编译apr的安装路径 )

下图为如何右击来下载 apr-util模块

然后再编译安装 httpd时必须添加如下两个 with参数,也是醉了:

[root@Franklin13 httpd-2.4.41]# ./configure –prefix=/usr/local/apache2.4.41 –sysconfdir=/etc/httpd2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util

[root@Franklin13 httpd-2.4.41]#

但出现了如下新的报错 “ pcre-config for libpcre not found”

故不得不下载 pcre模块,然后编译安装

之后,httpd源码包才能安装成功

[root@Franklin13 httpd-2.4.41]# history 5

502  ./configure –prefix=/usr/local/apache2.4.41 –sysconfdir=/etc/httpd2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-pcre=/usr/local/pcre

503  make

504  history 5

505  make install

506  history 5

安装成功后到安装路径目录下 /bin下运行 apachectl start即可

[root@Franklin13 bin]# pwd

/usr/local/apache2.4.41/bin

[root@Franklin13 bin]# apachectl start

[root@Franklin13 bin]# 

[root@Franklin13 bin]# netstat -tan|grep 80

tcp6       0      0 :::80                   :::*                    LISTEN     

[root@Franklin13 bin]# 

[root@Franklin13 bin]# 

[root@Franklin13 bin]# ps -ef|grep httpd

root      59193      1  0 16:27 ?        00:00:01 /usr/sbin/httpd -DFOREGROUND

apache    59199  59193  0 16:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

apache    59201  59193  0 16:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

apache    59203  59193  0 16:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

apache    59204  59193  0 16:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

apache    59205  59193  0 16:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND

root      63802  19545  0 17:46 pts/5    00:00:00 grep –color=auto httpd

[root@Franklin13 bin]# 

——————–   全文完 ———————————————————-

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。