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

相关推荐

  • 测试Markdown

    测试markdown是否可用

    Linux干货 2018-03-10
  • Linux 文本编辑器三剑客之 sed

    参考手册: http://www.gnu.org/software/sed/manual/sed.html 转载请注明:马哥教育!!

    Linux干货 2017-01-12
  • linux rpm包管理

    一、概要     RPM:RPM Package Manager(rpm软件包管理器)的缩写。它能将编译好的程序打包一个文件或有限的几个文件,可用于实现安装、卸载、升级、查询等功能。 二、rpm软件包管理 rpm包的命名格式:name-version-relase.arch.rpm 例如:bash-1.1.0-5.el…

    Linux干货 2015-04-27
  • 初入linux

    一、认识linux 1、在windows中通过盘符区分文件存放位置,而linux中没有盘符之说,只有文件和文件夹 2、在linux中,万物从根开始,没有后缀之说 二、文件系统的目录结构 /:根目录 /boot:系统启动的相关配置文件 /dev:设备文件 块设备:随机访问,数据块为单位 字符设备:线性访问,按字符为单位 设备号:主设备号(major)和次设备号…

    Linux干货 2017-05-20
  • N21天天第十四周课程练习

    系统的INPUT和OUTPUT默认策略为DROP; #把默认策略设置为DROP [root@localhost ~]# iptables -P INPUT DROP [root@localhost ~]# iptables -P OUTPUT DROP 1、限…

    Linux干货 2016-12-05
  • 正则表达式 小结

    听老师和学姐都说,正则表达式很重要,所以这次我总结一下,同时加强一下记忆。 目前我们学的正则表达式有:字符匹配;匹配字数;位置锚定。 :. 匹配任意单个字符 [] 匹配指定范围内的任意单个字符 [^] 匹配指定范围外的任意单个字符 [:alnum:] 或 [0-9a-zA-Z] [:alpha:] 或 [a-zA-Z]…

    2017-07-31