Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

Linux 手動編譯安裝 Apache 2.2.6 完整教程(RedHat 5.5 環境)

編輯:關於伺服器

前置準備

  • 系統:Red Hat Enterprise Linux 5.5
  • 安裝包:httpd-2.2.6.tar.bz2 放置於 /soft 目錄
  • 確保已安裝 gcc、make、openssl-devel 等編譯工具

編譯安裝步驟

cd /soft
tar jxvf httpd-2.2.6.tar.bz2
cd httpd-2.2.6

# 查看配置選項
./configure --help | more

# 配置:指定安裝路徑、啟用 DSO 模組支援
./configure --prefix=/usr/local/apache --enable-so

# 編譯與安裝
make
make install

配置與服務管理

1. 備份原始配置

cd /usr/local/apache/conf
cp httpd.conf httpd.conf.bak

2. 停用系統自帶 httpd(若存在)

chkconfig --list httpd
chkconfig httpd off
service httpd stop

3. 啟動 Apache 並驗證

/usr/local/apache/bin/apachectl -k start
netstat -an | grep :80
ps -aux | grep httpd

4. 加入系統服務實現開機自啟

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache
vi /etc/rc.d/init.d/apache
# 在 #!/bin/sh 下方新增:
#chkconfig: 2345 85 15

chkconfig --add apache
chkconfig --list apache

# 測試服務控制
service apache stop
netstat -an | grep :80
service apache start

驗證安裝

瀏覽器訪問伺服器 IP,若出現 Apache 預設歡迎頁面(原文誤寫為 Tomcat 頁面),即表示安裝成功。

常見問題提示

  • 若 80 埠被佔用,檢查是否殘留舊 httpd 進程:ps -aux | grep httpd 後 kill 掉
  • 防火牆需開放 80 埠:iptables -I INPUT -p tcp --dport 80 -j ACCEPT
  • SELinux 可能阻擋,建議設為 Permissive 或關閉
Copyright © Windows教程網 All Rights Reserved