源碼編譯安裝Apache

來源:互聯網
上載者:User

標籤:apache   源碼安裝   httpd   configure   


編譯安裝Apache

系統內容:centos 7.2

前提:

提供開發工具及開發環境

  • 開發工具:make, gcc等

  • 開發環境:開發庫,標頭檔

  • glibc:標準庫

方式:

通過“包組”提供開發組件

centos 6[[email protected] ~]# yum groupinstall "Development Tools"[[email protected] ~]# yum groupinstall "Development tools"centos 7 [[email protected] ~]# yum groupinstall "Development Tools"

1、首先在方法網站http://www.apache.org/下載源碼包

下載路徑:http://apache.fayea.com/httpd/httpd-2.2.31.tar.gz

2、我們將下載好的檔案放置在/root目錄下

3、我們可以看到源碼包的格式為.tar.gz 所有這裡我們要將源碼包進行解壓縮和拆包

[[email protected] ~]# tar xvzf httpd-2.2.31.tar.gz

4、執行完上述操作後,在目前的目錄即(/root)目錄下,我們可以看到httpd-2.2.31目錄,進入該目錄

[[email protected] ~]# cd httpd-2.2.31/

5、在該目錄下,有眾多的檔案,我們首先關注的是 README 檔案和 INSTALL 檔案

README 檔案主要簡單的介紹了[[email protected] httpd-2.2.31]# less READMEwhat is it? The latest version  documentation   installation    licensingCryptographic Software NoticeContactsAcknowledgments通過以上的說明可以使我們對Apache有一個簡單的瞭解INSTALL 檔案主要說明了安裝的方法[[email protected] httpd-2.2.31]# less INSTALL$ ./configure --prefix=PREFIX$ make$ make install$ PREFIX/bin/apachectl start

6、通過查看以上檔案,下面我們可以進行Apache的編譯安裝

首先我們來介紹下configure指令碼的參數說明

[[email protected] httpd-2.2.31]# ./configure --helpInstallation directories:指定預設的安裝位置  --prefix=PREFIX         install architecture-independent files in PREFIX                          [/usr/local/apache2]Fine tuning of the installation directories:預設檔案安裝位置  --bindir=DIR            user executables [EPREFIX/bin]  --sbindir=DIR           system admin executables [EPREFIX/sbin]  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]  ......  ......System types:交叉編譯選項  --build=BUILD     configure for building on BUILD [guessed]  --host=HOST       cross-compile to build programs to run on HOST [BUILD]  --target=TARGET   configure for building compilers for TARGET [HOST]Optional Features:可選特性  --disable-option-checking  ignore unrecognized --enable/--with options  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]  --enable-v4-mapped      Allow IPv6 sockets to handle IPv4 connections  ......  ......Optional Packages:可選包  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)  --with-included-apr     Use bundled copies of APR/APR-Util

6(1)這裡我們指定幾個簡單的選項即可:

[[email protected] httpd-2.2.31]# ./configure --prefix=/usr/local/http2 --sysconfdir=/etc/http2//該步驟執行完畢後,會結合 Makefile.in 檔案,在目前的目錄下產生 Makefile 檔案//出現error等資訊,說明配置失敗

6(2)執行make和make install命令(上一步執行成功後) 注意:要始終處於目前的目錄下,不要離開該目錄

[[email protected] httpd-2.2.31]# make[[email protected] httpd-2.2.31]# make install

7、啟動

[[email protected] httpd-2.2.31]# cd /usr/local/http2/bin[[email protected] bin]# ./apachectl start[[email protected] bin]# netstat -tapn | grep "80"tcp6       0      0 :::80                   :::*                    LISTEN      14611/http

8、測試

centos 6.8系統下測試

[[email protected] ~]# links 10.1.249.146//10.1.249.146 為以上編譯安裝Apache軟體的centos 7系統 的IP

650) this.width=650;" src="http://i.imgur.com/ZOq3YW3.png" style="margin:0px;padding:0px;border:0px;" alt="ZOq3YW3.png" />

在Windows系統下測試

任意一款瀏覽器下輸入:http://10.1.249.146/

650) this.width=650;" src="http://i.imgur.com/YOlk46U.png" style="margin:0px;padding:0px;border:0px;" alt="YOlk46U.png" />

注意:如果啟動成功但是卻始終訪問不了,則可能的原因是centos 7 的防火牆沒有關閉,所以建議關閉防火牆後在做測試

[[email protected] ~]# iptables -F

9、最後的配置

我們知道一個程式主要由4類檔案組成

  • 二進位檔案

  • 設定檔

  • 庫檔案

  • 協助文檔

    [[email protected] ~]# cd /usr/local/http2/[[email protected] http2]# lsbin  build  cgi-bin  error  htdocs  icons  include  lib  logs  man  manual  modules

以上4類檔案應該放置在系統特定的目錄下 或者通過修改系統相關的設定檔

(1)二進位檔案 bin目錄 添加其路徑到PATH環境變數即可

 [[email protected] http2]# vim /etc/profile.d/http.sh export PATH=/usr/local/http2/bin:$PATH[[email protected] http2]# echo $PATH/usr/local/http2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

(2)設定檔我們在編譯安裝時已經通過 --sysconfdir=/etc/http2 選項指定了

(3)庫檔案 lib目錄

[[email protected] http2]# vim /etc/ld.so.conf.d/http2.conf/usr/local/http2/lib

讓系統重建庫檔案路徑緩衝

[[email protected] apache2]# ldconfig -v快取檔案:/etc/ld.so.cache

(4)協助文檔 man

[[email protected] lib]# vim /etc/man_db.conf (centos 7)添加一行內容:MANDATORY_MANPATH           /usr/local/http2/man

(5)對於 include 標頭檔 採用軟連結的方式(/usr/include為系統標頭檔位置)

[[email protected] include]# ln -s /usr/local/http2/include/ /usr/include/http[[email protected] include]# ll -d /usr/include/httplrwxrwxrwx. 1 root root 25 Aug 23 20:46 /usr/include/http -> /usr/local/http2/include/[[email protected] include]# ll /usr/include/http/
至此安裝配置完成


本文出自 “似水流年” 部落格,請務必保留此出處http://sixijie123.blog.51cto.com/11880770/1841679

源碼編譯安裝Apache

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.