温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-07-06 22:12:04 来源:网络 阅读:704 作者:xiaoluogoal 栏目:系统运维

                                        如何在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


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

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


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


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


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


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

     第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

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


有时,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


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


第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

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


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

参考文章---- 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模块

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


然后再编译安装 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模块,然后编译安装


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


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



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

之后,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

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

安装成功后到安装路径目录下 /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]# 


--------------------   全文完 ----------------------------------------------------------



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI