CentOS7.3系统上编译安装httpd.2.4.25

本文所做的所有操作是在一部新安装的CentOS7.3系统上。

1.环境与配置

环境说明:VMware上安装的CentOS7.3系统,7.3完整版光盘做成的yum源    
配置:编译生成的所有的文件都存放在/usr/local/httpd24/这个目录下

2.安装GCC编译器

#安装Development tools这个软件包组
[root@pxe68 ~]# yum groupinstall -y "Development tools"
...           中间省略
Installing : gdb-7.6.1-94.el7.x86_64                                                                   36/91 
Installing : mokutil-0.9-2.el7.x86_64                                                                  37/91 
Installing : systemtap-client-3.0-7.el7.x86_64                                                         38/91 
Installing : libgnome-keyring-3.8.0-3.el7.x86_64                                                       39/91 
Installing : pakchois-0.4-10.el7.x86_64                                                                40/91 
Installing : neon-0.30.0-3.el7.x86_64                                                                  41/91 
Installing : subversion-libs-1.7.14-10.el7.x86_64                                                      42/91 
Installing : rsync-3.0.9-17.el7.x86_64                                                                 43/91 
Installing : perl-Git-1.8.3.1-6.el7_2.1.noarch                                                         44/91 
Installing : git-1.8.3.1-6.el7_2.1.x86_64                                                              45/91 
Updating   : libgomp-4.8.5-11.el7.x86_64                                                               46/91 
Installing : 1:emacs-filesystem-24.3-18.el7.noarch                                                     47/91 
Installing : gettext-common-devel-0.18.2.1-4.el7.noarch                                                48/91 
Installing : gettext-devel-0.18.2.1-4.el7.x86_64                                                       49/91 
Installing : perl-Test-Harness-3.28-3.el7.noarch                                                       50/91 
Installing : automake-1.13.4-3.el7.noarch                                                              51/91 
Installing : kernel-devel-3.10.0-514.el7.x86_64
Complete!

3.解压httpd源码包,并进入软件包目录内

[root@pxe68 ~]# ls -lh
total 6.2M
-rw-------. 1 root root 1.2K Apr 15 21:28 anaconda-ks.cfg
-rw-r--r--  1 root root 6.2M Apr 20 16:56 httpd-2.4.25.tar.bz2
#解压软件包
[root@pxe68 ~]# tar xf httpd-2.4.25.tar.bz2 
#进入解压目录内
[root@pxe68 ~]# cd httpd-2.4.25
[root@pxe68 httpd-2.4.25]# 
[root@pxe68 ~]# cd httpd-2.4.25
[root@pxe68 httpd-2.4.25]# ll
total 2008
-rw-r--r--  1 501 games   13496 Apr 16  2015 ABOUT_APACHE
-rw-r--r--  1 501 games   24450 Dec  2 19:36 acinclude.m4
...            #中间省略

4.编译安装

[root@pxe68 httpd-2.4.25]# ./configure --prefix=/usr/local/httpd24
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.

第一次编译安装失败了,提示缺少apr这个软件包,那就安装吧。

[root@pxe68 httpd-2.4.25]# yum install -y apr-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package apr-devel.x86_64 0:1.4.8-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                    Arch                    Version                        Repository             Size
===============================================================================================================
Installing:
 apr-devel                  x86_64                  1.4.8-3.el7                    base                  188 k

Transaction Summary
===============================================================================================================
Install  1 Package

Total download size: 188 k
Installed size: 771 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-devel-1.4.8-3.el7.x86_64                                                                1/1 
  Verifying  : apr-devel-1.4.8-3.el7.x86_64                                                                1/1 

Installed:
  apr-devel.x86_64 0:1.4.8-3.el7                                                                               

Complete!

apr安装完成了,再次编译,期待中!!

[root@pxe68 httpd-2.4.25]# ./configure --prefix=/usr/local/httpd24
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.

又失败了,提示缺少apr-util这个软件包,linux是不是真的很可爱???

安装apr-util这个软件包

[root@pxe68 httpd-2.4.25]# yum install -y apr-util-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package apr-util-devel.x86_64 0:1.5.2-6.el7 will be installed
--> Processing Dependency: openldap-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Processing Dependency: expat-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64
--> Running transaction check
---> Package expat-devel.x86_64 0:2.1.0-8.el7 will be installed
---> Package libdb-devel.x86_64 0:5.3.21-19.el7 will be installed
---> Package openldap-devel.x86_64 0:2.4.40-13.el7 will be installed
--> Processing Dependency: openldap(x86-64) = 2.4.40-13.el7 for package: openldap-devel-2.4.40-13.el7.x86_64
--> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.40-13.el7.x86_64
--> Running transaction check
---> Package cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2 will be installed
--> Processing Dependency: cyrus-sasl-lib(x86-64) = 2.1.26-20.el7_2 for package: cyrus-sasl-devel-2.1.26-20.el7_2.x86_64
--> Processing Dependency: cyrus-sasl(x86-64) = 2.1.26-20.el7_2 for package: cyrus-sasl-devel-2.1.26-20.el7_2.x86_64
---> Package openldap.x86_64 0:2.4.40-8.el7 will be updated
---> Package openldap.x86_64 0:2.4.40-13.el7 will be an update
--> Running transaction check
---> Package cyrus-sasl.x86_64 0:2.1.26-20.el7_2 will be installed
---> Package cyrus-sasl-lib.x86_64 0:2.1.26-19.2.el7 will be updated
---> Package cyrus-sasl-lib.x86_64 0:2.1.26-20.el7_2 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                        Arch                 Version                          Repository          Size
===============================================================================================================
Installing:
 apr-util-devel                 x86_64               1.5.2-6.el7                      base                76 k
Installing for dependencies:
 cyrus-sasl                     x86_64               2.1.26-20.el7_2                  base                88 k
 cyrus-sasl-devel               x86_64               2.1.26-20.el7_2                  base               310 k
 expat-devel                    x86_64               2.1.0-8.el7                      base                56 k
 libdb-devel                    x86_64               5.3.21-19.el7                    base                38 k
 openldap-devel                 x86_64               2.4.40-13.el7                    base               800 k
Updating for dependencies:
 cyrus-sasl-lib                 x86_64               2.1.26-20.el7_2                  base               155 k
 openldap                       x86_64               2.4.40-13.el7                    base               350 k

Transaction Summary
===============================================================================================================
Install  1 Package  (+5 Dependent packages)
Upgrade             ( 2 Dependent packages)

Total download size: 1.8 M
Downloading packages:
---------------------------------------------------------------------------------------------------------------
Total                                                                          8.6 MB/s | 1.8 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : cyrus-sasl-lib-2.1.26-20.el7_2.x86_64                                                      1/10 
  Updating   : openldap-2.4.40-13.el7.x86_64                                                              2/10 
  Installing : cyrus-sasl-2.1.26-20.el7_2.x86_64                                                          3/10 
  Installing : cyrus-sasl-devel-2.1.26-20.el7_2.x86_64                                                    4/10 
  Installing : openldap-devel-2.4.40-13.el7.x86_64                                                        5/10 
  Installing : libdb-devel-5.3.21-19.el7.x86_64                                                           6/10 
  Installing : expat-devel-2.1.0-8.el7.x86_64                                                             7/10 
  Installing : apr-util-devel-1.5.2-6.el7.x86_64                                                          8/10 
  Cleanup    : openldap-2.4.40-8.el7.x86_64                                                               9/10 
  Cleanup    : cyrus-sasl-lib-2.1.26-19.2.el7.x86_64                                                     10/10 
  Verifying  : cyrus-sasl-2.1.26-20.el7_2.x86_64                                                          1/10 
  Verifying  : apr-util-devel-1.5.2-6.el7.x86_64                                                          2/10 
  Verifying  : openldap-devel-2.4.40-13.el7.x86_64                                                        3/10 
  Verifying  : openldap-2.4.40-13.el7.x86_64                                                              4/10 
  Verifying  : expat-devel-2.1.0-8.el7.x86_64                                                             5/10 
  Verifying  : cyrus-sasl-lib-2.1.26-20.el7_2.x86_64                                                      6/10 
  Verifying  : libdb-devel-5.3.21-19.el7.x86_64                                                           7/10 
  Verifying  : cyrus-sasl-devel-2.1.26-20.el7_2.x86_64                                                    8/10 
  Verifying  : openldap-2.4.40-8.el7.x86_64                                                               9/10 
  Verifying  : cyrus-sasl-lib-2.1.26-19.2.el7.x86_64                                                     10/10 

Installed:
  apr-util-devel.x86_64 0:1.5.2-6.el7                                                                          

Dependency Installed:
  cyrus-sasl.x86_64 0:2.1.26-20.el7_2                  cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2               
  expat-devel.x86_64 0:2.1.0-8.el7                     libdb-devel.x86_64 0:5.3.21-19.el7                      
  openldap-devel.x86_64 0:2.4.40-13.el7               

Dependency Updated:
  cyrus-sasl-lib.x86_64 0:2.1.26-20.el7_2                    openldap.x86_64 0:2.4.40-13.el7                   

Complete!

安装完成,再次编译,再接再厉中!!

[root@pxe68 httpd-2.4.25]# ./configure --prefix=/usr/local/httpd24
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

抓狂,又提示缺少pcre-config这个东东,那就安装吧,无奈!!

[root@pxe68 httpd-2.4.25]# yum install -y pcre-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.x86_64 0:8.32-15.el7_2.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                    Arch                   Version                          Repository            Size
===============================================================================================================
Installing:
 pcre-devel                 x86_64                 8.32-15.el7_2.1                  base                 479 k

Transaction Summary
===============================================================================================================
Install  1 Package

Total download size: 479 k
Installed size: 1.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pcre-devel-8.32-15.el7_2.1.x86_64                                                           1/1 
  Verifying  : pcre-devel-8.32-15.el7_2.1.x86_64                                                           1/1 

Installed:
  pcre-devel.x86_64 0:8.32-15.el7_2.1                                                                          

Complete!

再战江湖

[root@pxe68 httpd-2.4.25]# make && make install
...           中间省略
Installing configuration files
mkdir /usr/local/httpd24/conf
mkdir /usr/local/httpd24/conf/extra
mkdir /usr/local/httpd24/conf/original
mkdir /usr/local/httpd24/conf/original/extra
Installing HTML documents
mkdir /usr/local/httpd24/htdocs
Installing error documents
mkdir /usr/local/httpd24/error
Installing icons
mkdir /usr/local/httpd24/icons
mkdir /usr/local/httpd24/logs
Installing CGIs
mkdir /usr/local/httpd24/cgi-bin
Installing header files
mkdir /usr/local/httpd24/include
Installing build system files
mkdir /usr/local/httpd24/build
Installing man pages and online manual
mkdir /usr/local/httpd24/man
mkdir /usr/local/httpd24/man/man1
mkdir /usr/local/httpd24/man/man8
mkdir /usr/local/httpd24/manual
make[1]: Leaving directory `/root/httpd-2.4.25'

一气呵成,终于成功了!!

好了,编译安装已经完成,接下来就要对系统进行配置了。

5.把httpd的可执行程序加入系统环境变量

#加入系统环境变量以后使用httpd就不再需要每次都输入其绝对路径,方便快捷。
[root@pxe68 httpd-2.4.25]# vi /etc/profile.d/httpd.sh
#在/etc/profile.d/这个目录新建一个httpd.sh的文件,加入以下内容:
PATH=$PATH:/usr/local/httpd24/bin/
export PATH
#然后保存退出,执行以下命令,使这个文件生效。
[root@pxe68 httpd-2.4.25]# source /etc/profile.d/httpd.sh

很奇怪我的这个系统竟然没有安装防火墙,那就暂时先不管这个了。

6.启动httpd

[root@pxe68 bin]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message 
[root@pxe68 bin]# ss -tuan
Netid State      Recv-Q Send-Q        Local Address:Port                       Peer Address:Port              
tcp   LISTEN     0      128                       *:22                                    *:*                  
tcp   LISTEN     0      100               127.0.0.1:25                                    *:*                  
tcp   ESTAB      0      52            192.168.81.88:22                         192.168.81.1:60469              
tcp   LISTEN     0      128                      :::80                                   :::*                  
tcp   LISTEN     0      128                      :::22                                   :::*                  
tcp   LISTEN     0      100                     ::1:25                                   :::*

可以看到系统中的80端口已经开启

打开系统浏览器,输入虚拟机的IP地址,回车,可以看到以下界面,说明apache已经在工作了。

CentOS7.3系统上编译安装httpd.2.4.25

 

#进入apache存放默认存放网页的目录
[root@pxe68 httpd24]# cd htdocs/
[root@pxe68 htdocs]# ll
total 4
-rw-r--r-- 1 root root 45 Jun 12  2007 index.html

[root@pxe68 htdocs]# vi index.html 
#编辑index.html文件,把原有内容换成以下内容
<html><body><h1>Hello world!</h1></body></html>

刷新浏览器,可以看到网页内容变了,再次确认apache在工作中。

CentOS7.3系统上编译安装httpd.2.4.25

 

7.把httpd的库文件加入到系统的库中,这样别的软件包就也使用这些库文件了。

[root@pxe68 htdocs]# vi /etc/ld.so.conf.d/httpd.conf
/usr/local/httpd24/modules
[root@pxe68 htdocs]# ldconfig
#让系统生成库文件的缓存

8.把httpd的man文档加入到系统的man库中,方便随时调用

[root@pxe68 htdocs]# vi /etc/man_db.conf
 20 MANDATORY_MANPATH                       /usr/man
 21 MANDATORY_MANPATH                       /usr/share/man
 22 MANDATORY_MANPATH                       /usr/local/share/man
 23 MANDATORY_MANPATH                       /usr/local/httpd24/man
 #在第22行下边加入httpd的man文件的地址

大功告成!!

原创文章,作者:renpingsheng,如若转载,请注明出处:http://www.178linux.com/73820

(0)
上一篇 2017-04-20 22:52
下一篇 2017-04-21 09:52

相关推荐

  • IP地址之IPv4

    一、概述   IP地址有IPv4和IPv6两个版本,目前我们通常所说的IP地址是指IPv4。   IP地址由32位的二进制数组合而成,为了方便人类记忆,将二进制转换成4个十进制的数值。   在这32位数据中分为网络号与主机号两个部分。 二、IP的分级   IP网段分为五个等级,其定义如下:   A类:规定前面…

    Linux干货 2016-02-14
  • 马哥教育网络班22期+第8周课程练习 忍者乱太郎喻成

    第八周 1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 一个好的链接,主要的参考http://www.cnblogs.com/imapla/archive/2013/03/12/2955931.html简单的总结和自己的理解桥接器(network bridge),又称网桥,一种网络设备,负责网络桥接(network …

    Linux干货 2016-12-26
  • 浏览和管理log文件

    浏览和管理log文件 log文件是一种包含系统消息的文件,包括内核、服务和应用运行在其上。不同的日志文件对应不同的日志信息。例如,默认的系统log文件,一个log文件对应安全消息,一个log文件对应计划任务。当要对一个系统问题排错例如加载内核驱动或者当寻找对系统的非授权登录攻击,日志文件是很有帮助的。一些log文件被一个称之为rsyslogd的守护进程控制。…

    Linux干货 2017-05-15
  • vim编辑器及shell基础

    1、复制/etc/rc.d/rc.sysint文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#cp /etc/rc.d/rc.sysint /tmpvim /tmp/rc.sysint:%s@^[[:space:]]\+@#&@g 2、复制/boot/grub/grub.conf至/tmp目录中,删除/…

    Linux干货 2017-12-08
  • grep 正则表达式 find

    1.显示当前系统上root,fedora 或user1用户的默认shell [root@centos7 ~]# grep -E  “^(root|fedora|user1)” /etc/passwd root:x:0:0:root:/root:/bin/bash fedora:x:2003:2003::/home/fedora:/bi…

    2017-09-18
  • Linux发展史

    适用对象:本文适合希望开始学习以及想了解Linux的朋友阅读。本文中所有内容仅供参考,不作为科学依据。 一、      Linux的起源 最初的计算机其实是具有单一功能的大型计算器,只能完成指定或者设定好的工作。多数情况下计算机资源是处于空闲状态的,为了不使资源浪费,就需要使计算机能够或者可以进行多种工作。或…

    Linux干货 2016-10-14