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

相关推荐

  • GPG——另一种加密信息的方式

    GPG ·使用gpg实现对称加密 ·对称加密file文件          gpg -c file          ls file.gpg ·在另一台主机上解密file   &n…

    Linux干货 2016-09-22
  • PHP的类自动加载机制

    在PHP开发过程中,如果希望从外部引入一个class,通常会使用include和require方法,去把定义这个class的文件包含进来。这个在小规模开发的时候,没什么大问题。但在大型的开发项目中,这么做会产生大量的require或者include方法调用,这样不因降低效率,而且使得代码难以维护,况且require_once的代价很大。 在PHP5之前,各个…

    Linux干货 2015-04-10
  • DNS基础及使用BIND搭建域名服务器

        本文主线是DNS服务相关概念和服务器搭建,在此之前了解一下域名这个东东很有其必要性,因为DNS服务就是应域名而生的。那么域名是什么哪?     域名     域名是用一串用点分开的字符串来表示的internet上的某一台或者一组计算机的名称,用于在数据传输时标识计算机的电子方位。举…

    Linux干货 2015-06-11
  • 网络知识点

    1. 实现异地搭建局域网的方法1>. 让运行商拉专线,这是相当昂贵的。2>.  VPN (Virtual PrivateNetwork)  虚拟专用网络 2. VPN的隧道协议主要有三种:PPTP、L2TP和IPSec。其中PPTP和L2TP协议工作在OSI模型的第二层,又称为二层隧道协议;IPSec是第三层隧道协议。 2. …

    Linux干货 2016-09-01
  • Shell脚本-循环基础

    Shell脚本-循环基础 背景: 正在学习Shell脚本之循环,发现Shell的循环和其他编程语言大同小异,逻辑上都是相通的,但在使用格式上却有点不同,在学习完Shell循环后,将学习的心得体会记录下来,以备今后复习。 介绍: 什么是Shell脚本:       shell script是利用shell的功能…

    2017-08-26
  • Linux文件权限及ACL

    1、文件权限:          文件的权限主要针对三类对象进行定义:                owner:属主,u表示  …

    Linux干货 2016-08-05