CentOS6.9系統上編譯安裝httpd.2.2.32

本文所做的所有操作是在一部新安裝的CentOS6.9系統上。

1.環境與配置

環境說明:VMware上安裝的CentOS6.9系統,兩張系統盤做成的yum源    
配置:編譯生成的所有的文件都存放在/usr/local/httpd22/這個目錄下

2.安裝GCC編譯器

[root@localhost ~]# yum grouplist | grep "Development tools"
   Development tools
#安裝Developmnt tools這個軟件包組
[root@localhost ~]# yum groupinstall -y "Development tools"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
...          #中間省略
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Package 1:pkgconfig-0.23-9.1.el6.x86_64 already installed and latest version
Package binutils-2.20.51.0.2-5.46.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.63-5.1.el6 will be installed
--> Processing Dependency: perl >= 5.005_03 for package: autoconf-2.63-5.1.el6.noarch
--> Processing Dependency: perl >= 5.005 for package: autoconf-2.63-5.1.el6.noarch
...         #中間省略
Verifying  : elfutils-0.164-2.el6.x86_64                               106/113 
Verifying  : 1:perl-Module-Pluggable-3.90-144.el6.x86_64               107/113 
Verifying  : byacc-1.9.20070509-7.el6.x86_64                           108/113 
Verifying  : libXft-2.3.2-1.el6.x86_64                                 109/113 
Verifying  : libedit-2.11-4.20080712cvs.1.el6.x86_64                   110/113 
Verifying  : libICE-1.0.6-1.el6.x86_64                                 111/113 
Verifying  : perl-XML-Parser-2.36-7.el6.x86_64                         112/113 
Verifying  : libxcb-1.12-4.el6.x86_64                                  113/113 
...         #中間省略                                    
ppl.x86_64 0:0.10.2-11.el6                                                     
rsync.x86_64 0:3.0.6-12.el6                                                   
systemtap-client.x86_64 0:2.9-7.el6                                            
systemtap-devel.x86_64 0:2.9-7.el6                                             
systemtap-runtime.x86_64 0:2.9-7.el6                                           
unzip.x86_64 0:6.0-5.el6                                                       
xz.x86_64 0:4.999.9-0.5.beta.20091007git.el6                                   
xz-lzma-compat.x86_64 0:4.999.9-0.5.beta.20091007git.el6                       
zip.x86_64 0:3.0-1.el6_7.1                                                     
Complete!

可以看到這次總共安裝了113個軟件包。

3.解壓httpd源碼包,并進入軟件包目錄內

#解壓軟件包
[root@localhost ~]# ll -h httpd-2.2.32.tar.bz2 
-rw-r--r--. 1 root root 5.6M Apr 20 16:56 httpd-2.2.32.tar.bz2
 [root@localhost ~]# tar xf httpd-2.2.32.tar.bz2 
[root@localhost ~]# ll -h
total 5.6M
drwxr-xr-x. 11 1001 1001 4.0K Jan 10 01:36 httpd-2.2.32
-rw-r--r--.  1 root root 5.6M Apr 20 16:56 httpd-2.2.32.tar.bz2
#進入解壓后的目錄
[root@localhost ~]# cd httpd-2.2.32
[root@localhost httpd-2.2.32]# ll
total 1172
-rw-r--r--.  1 1001 1001  14882 Nov 22  2004 ABOUT_APACHE
-rw-r--r--.  1 1001 1001  18613 Jul  6  2012 acinclude.m4
-rw-r--r--.  1 1001 1001  56952 Oct  6  2010 Apache.dsw
drwxr-xr-x.  6 1001 1001   4096 Jan 10 01:36 build
-rw-r--r--.  1 1001 1001   2644 Aug 24  2007 BuildAll.dsp
...          #中間省略
drwxr-xr-x.  3 1001 1001   4096 Jan 10 01:36 server
drwxr-xr-x.  5 1001 1001   4096 Jan 10 01:36 srclib
drwxr-xr-x.  4 1001 1001   4096 Jan 10 01:36 support
drwxr-xr-x.  2 1001 1001   4096 Jan 10 01:36 test
-rw-r--r--.  1 1001 1001   8183 Oct 18  2005 VERSIONING

4.編譯安裝

[root@localhost httpd-2.2.32]# ./configure --prefix=/usr/local/httpd22
...          #中間省略    
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands

可以看到中間沒有報錯,可以進入下一步了。

[root@localhost httpd-2.2.32]# make && make install
...          #中間省略
make[2]: Leaving directory `/root/httpd-2.2.32/modules/mappers'
make[2]: Entering directory `/root/httpd-2.2.32/modules'
make[2]: Leaving directory `/root/httpd-2.2.32/modules'
make[1]: Leaving directory `/root/httpd-2.2.32/modules'
Making install in support
make[1]: Entering directory `/root/httpd-2.2.32/support'
make[2]: Entering directory `/root/httpd-2.2.32/support'
make[2]: Leaving directory `/root/httpd-2.2.32/support'
make[1]: Leaving directory `/root/httpd-2.2.32/support'
make[1]: Entering directory `/root/httpd-2.2.32'
Installing configuration files
mkdir /usr/local/httpd22/conf
mkdir /usr/local/httpd22/conf/extra
mkdir /usr/local/httpd22/conf/original
mkdir /usr/local/httpd22/conf/original/extra
Installing HTML documents
mkdir /usr/local/httpd22/htdocs
Installing error documents
mkdir /usr/local/httpd22/error
Installing icons
mkdir /usr/local/httpd22/icons
mkdir /usr/local/httpd22/logs
Installing CGIs
mkdir /usr/local/httpd22/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/httpd22/man
mkdir /usr/local/httpd22/man/man1
mkdir /usr/local/httpd22/man/man8
mkdir /usr/local/httpd22/manual
make[1]: Leaving directory `/root/httpd-2.2.32'

好了,編譯安裝已經完成,接下來就要對系統進行配置了。

5.把httpd的可執行程序加入系統環境變量

#加入系統環境變量以后使用httpd就不再需要每次都輸入其絕對路徑,方便快捷。

[root@localhost httpd-2.2.32]# vi /etc/profile.d/httpd.sh
#在/etc/profile.d/這個目錄新建一個httpd.sh的文件,加入以下內容:
PATH=$PATH:/usr/local/httpd22/bin
export PATH
然后保存退出,執行以下命令,使這個文件生效。
[root@localhost httpd-2.2.32]# source  /etc/profile.d/httpd.sh

6.關閉系統防火墻

[root@localhost httpd-2.2.32]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:

7.啟動httpd

[root@localhost httpd-2.2.32]# apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
#這個報錯可以暫時不用理會,不關系到本次試驗的成敗
[root@localhost httpd-2.2.32]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1333/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1412/master         
tcp        0      0 :::80                       :::*                        LISTEN      27285/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      1333/sshd           
tcp        0      0 ::1:25

可以看到系統中的80端口已經開啟

打開系統瀏覽器,輸入虛擬機的IP地址,回車,可以看到以下界面,說明apache已經在工作了。

CentOS6.9系統上編譯安裝httpd.2.2.32

#進入apache存放默認存放網頁的目錄
[root@localhost httpd-2.2.32]# cd /usr/local/httpd22/htdocs/
[root@localhost htdocs]# ls
index.html

[root@localhost htdocs]# vi index.html 
#編輯index.html文件,把原有內容換成以下內容
<html><body><h1>Hello world!</h1></body></html>

刷新瀏覽器,可以看到網頁內容變了,再次確認apache在工作中。

CentOS6.9系統上編譯安裝httpd.2.2.32

8.把httpd的庫文件加入到系統的庫中,這樣別的軟件包就也使用這些庫文件了。

[root@localhost htdocs]# vi /etc/ld.so.conf.d/httpd.conf
[root@localhost htdocs]# ldconfig
#讓系統生成庫文件的緩存

9.把httpd的man文檔加入到系統的man庫中,方便隨時調用

[root@localhost htdocs]# vi /etc/man.config

 43 MANPATH /usr/man
 44 MANPATH /usr/share/man
 45 MANPATH /usr/local/man
 46 MANPATH /usr/local/share/man
 47 MANPATH /usr/X11R6/man
 48 MANPATH /usr/local/httpd22/man
#在第47行下邊加入httpd的man文件的地址

大功告成!!So easy吧!

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

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

相關推薦

  • 馬哥教育網絡20期+第8周練習博客

    1、請描述網橋、集線器、二層交換機、三層交換機、路由器的功能、使用場景與區別。 網橋:鏈接層設備,基于MAC地址過濾。 集線器:物理層設備,基本都屬于半雙工模式。集線器與網橋在現在的局域網中基本都不用了。 二層交換機:基本MAC轉發數據,功能齊全的可支持VLAN等功能。常見的有100/1000M、16口/24口/48口。 三層交換機:功能齊全的交換機,具備都…

    Linux干貨 2016-08-01
  • DNS和BIND配置(第一部分)

    一、知識整理 1、最初只有七個一級域名:Top Level Domain:tld:com、edu、mil、gov、net、org、int;     一級域名分三類:組織域、國家域、反向域。最多127級域名;全球有13個根節點服務器。 2、一次完整的查詢請求經過的流程:client—hosts文件&#8212…

    Linux干貨 2016-10-17
  • Linux系統發展歷史

    一、什么是Linux? Linux是一種自由和開放源代碼的類UNIX操作系統。該操作系統的內核由林納斯·托瓦茲在1991年10月5日首次發布。在加上用戶空間的應用程序之后,成為Linux操作系統。Linux也是自由軟件和開放源代碼軟件發展中最著名的例子。只要遵循GNU通用公共許可證,任何個人和機構都可以自由地使用Linux的所有底層源代碼,也可以自由地修改和…

    Linux干貨 2016-10-14
  • Ubuntu 葵花寶典入門篇——要練此功,可能得自宮?

        此文章給初入ubuntu的小伙伴們寫一篇裝機篇和使用心得。第二期會給小伙伴介紹軟件安裝篇。如題目所說,烏班圖確實是葵花寶典,練好了天下無敵。只是如果要安裝UBUNTU系統,只是在虛擬機上跑跑是不夠的,你必須在實際的桌面環境和服務器環境上才能體會到它的運行方式,而桌面環境和服務器環境幾乎差不多。所以安裝桌面版可以更好的理解…

    Linux干貨 2017-03-26
  • linux的發展史

                  linux的發展史     1  Linux的誕生:    1988年:芬蘭赫爾辛基大學迎來一位新生-linus benedict torvalds (后面簡稱linus)   2 &nbsp…

    Linux干貨 2016-10-19
  • 系統管理之程序包管理(一) rpm詳解

    系統管理之程序包管理(1):     程序包管理是運維人員的基本工作素質之一。在操作系統上,不斷的安裝,卸載,配置應用程序包,讓不同程序包運行提供不同的服務;利用某種工具完成某些操作的過程。這就要求運維工作人員熟悉安裝,管理應用程序包。 在linux上,程序包主要有兩種:tar,rpm包。 一、程序包概述: 系統接口   &nb…

    Linux干貨 2016-08-21

評論列表(1條)

  • renjin
    renjin 2017-04-28 14:13

    文章詳細的介紹了httpd的編譯安裝的過程,流程寫的很詳細,666

欧美性久久久久