# Oracle Linux 9.4 安裝 Apache 2.4.62 [LABSPACE](https://web.labspace.com.tw) 在 Oracle Linux 9.4 上,如果您需要安裝特定版本的 Apache,例如 2.4.62,可以考慮透過編譯源碼的方式進行,因為 Oracle Linux 預設軟體倉中可能不會提供2.4.62版本(截至2024/11/03尚未提供)。 以下是安裝 Apache 2.4.62 的步驟: ### 1\. 安裝編譯所需的依賴項 首先,更新系統並安裝 Apache 編譯所需的依賴項: ```bash sudo dnf update -y sudo dnf groupinstall "Development Tools" -y sudo dnf install -y wget openssl-devel pcre-devel expat-devel libtool ``` #### 補充:同時也安裝openssl 查看版本 ```bash openssl version ```  ### 2\. 下載 Apache 2.4.62 源碼 接著,從 Apache 官方網站下載 Apache 2.4.62 的源碼壓縮檔: ```bash cd /usr/local/src sudo wget https://downloads.apache.org//httpd/httpd-2.4.62.tar.gz ``` ### 3\. 解壓縮源碼檔案 下載完成後,解壓縮源碼壓縮包: ```bash sudo tar -xzf httpd-2.4.62.tar.gz cd httpd-2.4.62 ``` ### 4\. 下載ARP、APR-util Apache Portable Runtime (APR) 和 APR Utility (APR-util) 庫。將 APR 和 APR-util 放入 Apache 源碼的 srclib 目錄下。 #### 使用備用的 APR 下載連結 下載 APR 和 APR-util 進入 Apache 源碼的 srclib 目錄並下載 APR 和 APR-util 源碼: ```bash cd srclib # 下載 APR sudo wget https://archive.apache.org/dist/apr/apr-1.7.4.tar.gz # 下載 APR-util sudo wget https://archive.apache.org/dist/apr/apr-util-1.6.3.tar.gz ``` ### 5\. 解壓縮並重命名 下載完成後,解壓並重命名目錄: ```bash sudo tar -xzf apr-1.7.4.tar.gz sudo tar -xzf apr-util-1.6.3.tar.gz sudo mv apr-1.7.4 apr sudo mv apr-util-1.6.3 apr-util ``` ### 6\. 配置編譯選項 配置編譯選項。這一步會創建 `Makefile` 文件,根據需求可以自定義安裝位置或啟用其他模組: ```bash cd .. sudo ./configure --enable-so --enable-ssl --with-mpm=event --with-included-apr ``` ### 7\. 編譯並安裝 執行以下命令進行編譯和安裝: ```bash sudo make sudo make install ``` 這會將 Apache 安裝到 `/usr/local/apache2` 目錄中。 ### 8\. 更新 PATH 並啟動 Apache 將新安裝的 Apache 加入到系統的 PATH 中: ```bash echo 'export PATH=/usr/local/apache2/bin:$PATH' | sudo tee -a /etc/profile source /etc/profile ``` ### 9\. 配置 `ServerName` 參數 若要避免 `ServerName` 警告,可以編輯 Apache 配置檔案 `httpd.conf`,設定 `ServerName` 為本機 IP 地址或主機名稱。例如: ```bash sudo vim /usr/local/apache2/conf/httpd.conf ``` 在 `httpd.conf` 中加入以下內容: ```apache ServerName 127.0.0.1 ``` ### 10\. 安裝 `lynx` 如果您需要在伺服器上使用 `apachectl status` 指令,可以安裝 `lynx`: ```bash sudo yum install lynx -y ``` 啟動 Apache: ```bash sudo /usr/local/apache2/bin/apachectl start ``` ### 11\. 確認 Apache 版本 確認是否安裝成功: ```bash httpd -v ```  這應顯示 Apache 2.4.62 的版本資訊。 ### 12\. 確認 Apache 服務狀態 最後,檢查 Apache 服務是否成功啟動: ```bash sudo /usr/local/apache2/bin/apachectl status ```  開啟網頁確認服務有正常Work!  # <img src="https://labspace.com.tw/assets/upload/product//LabSpace-logo-B-03.png" style="float: left; margin-right: 0.5rem;margin-top:-0.3rem; height: 45px;"> 層次數位空間有限公司 若想要瞭解更多技術資訊或者希望有人可以協助佈建,可洽[層次數位空間有限公司](https://labspace.com.tw) # !! 一個念頭與想法 !! 您有一個很棒的主意或想法嗎?我們聆聽並為您提供快速分析與規劃提案。層次數位讓您的系統平台更有層次。 [](https://web.labspace.com.tw)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up