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安裝完成了,再次編譯,期待中?。?/p>

[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這個東東,那就安裝吧,無奈?。?/p>

[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文件的地址

大功告成?。?/p>

原創文章,作者:renpingsheng,如若轉載,請注明出處:http://www.www58058.com/73820

(0)
renpingshengrenpingsheng
上一篇 2017-04-20
下一篇 2017-04-21

相關推薦

  • TCP連接的狀態轉移

    TCP是一個面向連接的傳輸層協議,因此不論哪一方需要傳輸數據,都需要在雙方之間建立一條傳輸連接。 用TCP的三次握手與四次揮手來解釋TCP的各個狀態之間的會比較清晰。 一、TCP的三次握手: a)         單方主動發起連接: 1、  服務器端應用層的應用程序創建…

    2017-03-19
  • 數組

    一.數組 變量:存儲單個元素的內存空間 數組:存儲多個元素的連續的內存空間,相當于多個變量的集合。 索引:編號從0 開始,屬于數值索引  注:索引可支持使用自定義的格式,而不僅是數值格式,即為關聯索引,bash4.0 版本之后開始支持,bash 的數組支持稀疏格式(索引不連續) 二.數組的聲明 declare -a ARRAY_NAME decla…

    Linux干貨 2016-11-23
  • 馬哥教育網絡班22期+第5周課程練習

    1、顯示當前系統上root、fedora或user1用戶的默認shell; [root@localhost ~]# awk -F: '{print $1,$7}' /etc/passwd| egrep "^\<(root|fedora|user…

    Linux干貨 2016-09-15
  • 文本三劍客—sed 基礎

    文本三劍客—sed 基礎        sed編輯器被稱作流編輯器(stream editor),和普通的交互式文本編輯器恰好相反。在交互式文本編輯器中(比如vim),你可以用鍵盤命令來交互式的插入、刪除或者替換數據中的文本。流編輯器則會自愛編輯器處理數據之前基于預習提供的一組…

    Linux干貨 2017-05-15
  • Linux 基礎知識(六.二)

    1、復制/etc/rc.d/rc.sysinit至/tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加# [root@server01 tmp]# cp /etc/rc.d/rc.sysinit /tmp/ [root@server01 tmp]# sed -n "s@^[[:space:]]\+@#&@…

    Linux干貨 2016-11-14
  • 磁盤管理

    磁盤管理     設備文件         I/O Ports: I/O設備地址         一切皆文件:     …

    Linux干貨 2016-09-01
欧美性久久久久