溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

使用源碼包編譯安裝apache2.4

發(fā)布時間:2020-07-19 07:49:04 來源:網(wǎng)絡(luò) 閱讀:202 作者:huai251459 欄目:系統(tǒng)運維

一、前言

為了更好地理解學(xué)習(xí)Linux系統(tǒng)程序包的編譯安裝,因此自己嘗試編譯安裝了apache,本文記錄了編譯安裝的過程和相應(yīng)出現(xiàn)的報錯及解決辦法,以供之后再次翻閱。

二、環(huán)境準(zhǔn)備

系統(tǒng)版本:CentOS Linux release 7.2.1511 (Core)

內(nèi)核版本:3.10.0-327.el7.x86_64

在進(jìn)行編譯安裝前,我也在網(wǎng)上翻閱了不少資料,基本上都在進(jìn)行編譯安裝前均需要安裝相關(guān)的依賴軟件包,使用yum安裝依賴包如:

yum install -y gcc gcc++ zlib zlib-devel expat-devel pcre-devel

上述部分是一些常見的依賴包,expat-devel和pcre-devel是我在安裝過程中報錯后補充的。

隨后使用wget命令下載相應(yīng)的源碼包到指定的目錄:

httpd:http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.29.tar.gz

apr:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz

apr-util:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

準(zhǔn)備工作做完就可以進(jìn)行編譯安裝了

三、編譯安裝

在編譯安裝httpd的源碼包之前,我們得下編譯安裝apr和apr-until這兩個對應(yīng)源碼包。

1、安裝apr

[root@localhost tmp]# tar xf apr-1.6.3.tar.gz

[root@localhost tmp]# cd apr-1.6.3

[root@localhost apr-1.6.3]#./configure--prefix=/usr/local/apr

[root@localhost apr-1.6.3]# make&&make install

2、安裝apr-util

[root@localhost tmp]# tar xf apr-util-1.6.1.tar.gz

[root@localhost tmp]# cd apr-util-1.6.1

[root@localhost apr-util-1.6.1]#./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr

[root@localhost apr-util-1.6.1]# make&&make install

3、安裝httpd

[root@localhost tmp]# tar xf httpd-2.4.29.tar.gz

[root@localhost tmp]# cd httpd-2.4.29

[root@localhost httpd-2.4.29]#./configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util

[root@localhost httpd-2.4.29]# make&&make install

四、編譯安裝完成后的工作

1、啟動Apache

[root@localhost~]# cd/usr/local/apache/bin/

[root@localhost bin]#./apachectl start

程序安裝完成之后想要被運行起來,就必須為其中的二進(jìn)制程序文件制定環(huán)境變量,否則只能通過路徑來執(zhí)行,這樣每次都要輸入

很長一部分路徑,當(dāng)然也可以使用別名,但比較環(huán)境變量來說,環(huán)境變量還是簡潔明了的。在系統(tǒng)上通過$PATH變量來制定系

統(tǒng)中的二進(jìn)制程序路徑信息,自己編譯的程序的二進(jìn)制執(zhí)行文件一般不會在此變量中,我們手動加入即可

使用:

echo 'export PATH=/usr/local/src/httpd/bin:$PATH' > /etc/profile.d/httpd.sh

這樣就可以直接使用apachectl start|stop|status這樣的命令直接管理httpd了

apachectl start :啟動后使用瀏覽器輸入IP測試一下

除了二進(jìn)制文件之外還有庫文件,因為大多數(shù)應(yīng)用程序都依賴與標(biāo)準(zhǔn)庫某些共享文件。

Linux默認(rèn)找?guī)煳募窂剑?lib64,/lib,/usr/lib64,/usr/lib

編輯/etc/ld.so.conf.d/httpd.conf,添加搜索路徑至此文件中

寫入:/usr/local/httpd/lib64

執(zhí)行l(wèi)dconfig命令,重新生成庫映射

還有頭信息,創(chuàng)建符號連接

ln -s /usr/local/httpd/include /usr/include/httpd

ln -s /usr/local/httpd/include/* /usr/include/

還有man文檔,編輯/etc/man.config,找到MANPATH

MANPATH /usr/lcoal/httpd/man

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI