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)
renpingshengrenpingsheng
上一篇 2017-04-20
下一篇 2017-04-21

相关推荐

  • Linux文件的权限与解析

    一,文件的基本权限: 通常,你使用ls -l 命令,就会看到这样的行:   让我们解析一下这些字段代表的意思: -rw-r–r–. 1 root root 1018 Nov 6 2016 usb_modeswitch.conf 文件类型权限  硬链接数 文件所有者 文件所属组 文件容量  文件最后被修改时…

    2017-07-30
  • linux的管道命令和用户管理命令

    1、列出当前系统上的所有已经登录的用户的用户名 [root@localhost home]# who | cut -d” ” -f1 | uniq root test root 2、取出最后登录到当前系统的用户相关信息 [root@localhost home]# who | tail -1 root pts/3 2017-07-16 19:38 (192.…

    Linux干货 2017-07-17
  • mysqld_multi 多实例部署

    序言:多实例?Why?   随着硬件层面的发展,linux系统多核已经是普通趋势,而mysql是单进程多线程,所以先天上对多进程的利用不是很高,虽然5.6版本已经在这方面改进很多,但是也没有达到100%,所以为了充分的利用系统资源,mysql有自己的补充,那就是可以部署多实例,一个实例一个端口。     1,准备好mysql环境…

    2017-11-16
  • Centos 7 DNS配置及理论详解

    DNS是什么及BIND讲解内容 域名系统(英文:Domain Name System,缩写:DNS)是internet的一项服务。它作为将域名和IP地址相互映射服务,能够使人更方便地访问互联网。DNS使用TCP和UDP端口53。当前,对于每一级域名长度的限制是63个字符,域名总长度则不能超过253个字符。讲解内容:    DNS名称解析方…

    Linux干货 2016-04-25
  • 第八周作业

    1、写一个脚本,使用ping命令探测172.16.250.1-172.16.250.254之间的所有主机的在线状态;     在线的主机使用绿色显示;     不在线的主使用红色显示; #!/bin/bash for i in {1..254};do if ping -c 1 -w 1 192.16…

    2017-07-03