1. 程式人生 > 實用技巧 >編譯安裝http2.4

編譯安裝http2.4

僅以部落格形式記錄linux所學,不足之處繼續優化

linux系統(centos)的軟體安裝一般分為2中,一是rpm包安裝(yum,dnf都是基於rpm包),一是原始碼包編譯安裝。

實際應用場景中,原始碼包編譯安裝較為常用,因為它可以實現個性化,定製化,隨你的需要定向安裝到某個資料夾,啟動或者禁用某些功能。

原始碼編譯首先要安裝編譯工具gcc

yum install -y gcc

原始碼編譯安裝一般是三步

1,進入到原始碼包下一般都會有configure檔案,即configure指令碼,在執行時你可以指定安裝位置、指定啟用的特性

具體的可以看./configure --help

安裝路徑設定

--prefix=/PATH:指定預設安裝位置,預設為/usr/local/
--sysconfdir=/PATH:配置檔案安裝位置

可選特性

--disable-FEATURE
--enable-FEATURE[=ARG]

依賴包

--with-PACKAGE[=ARG] 依賴包
--without-PACKAGE 禁用依賴關係

2,make  根據Makefile檔案,構建應用程式

3,make install  複製檔案到相應路徑

centos7虛擬機器測試

將httpd-2.4.25.tar.bz2上傳到/data下

解壓

tar xvf httpd-2.4.25.tar.bz2

利用configure編譯

[root@centos7 httpd-2.4.25]# ./configure --prefix=/apps/httpd2.4.25 \
> --sysconfdir=/etc/httpd \
> --enable-ssl \
> --enable-so    #指定安裝路徑,配置檔案路徑,ssl證書
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未找到

一般這種問題就是缺少這個依賴包,這個依賴包的名字一般情況是apr-devel

yum install apr-devel

接下來如果還報類似的錯誤,重複上述操作。

上述./configure執行工需要安裝4個依賴包

apr-devel
apr-util-devel
pcre-devel
openssl-devel

此時可以看到已經生成makefile檔案

接下來直接執行make && make install

因為是安裝在/apps下的,啟動軟體/apps/httpd2.4.25/bin/httpd.就啟動了軟體