Apache2のインストール方法 on CentOS4.4(ソースから2.0.59)

ソースから入れる機会があったのでおさらいします。

  • OSはCentOS4.4です。

まずはパッケージとして入っていないかチェック。入っていたら削除しておく

#rpm -qa | grep http

ソースをダウンロード

Apacheのサイトはこちら
Download - The Apache HTTP Server Project
http://httpd.apache.org/download.cgi

2.0.59をソースを落としてきます。

解凍

#tar xvfz httpd-2.0.59.tar.gz 

解凍先へ移動

#cd httpd-2.0.59

コンパイルを実行(ここで不足パッケージなどのエラーに対処します)

#./configure
#make
#make install

自動起動スクリプトをコピー

#cp -p build/rpm/httpd.init /etc/rc.d/init.d/httpd

自動起動スクリプトを編集。パスの相違点を直します。

/usr/sbin/apachectl ⇒ =/usr/local/apache2/apachectl
/usr/sbin/httpd ⇒ /usr/local/apache2/bin/httpd

自動起動の設定

#chkconfig --add httpd

Apacheの起動

#/etc/rc.d/init.d/httpd start

インストールされたことをブラウザで確認

http://xx.xx.xx.xx/

何かページを作ってみる

#/usr/local/apache2/htdocs
#vi hello.html

hello.htmlの内容

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
  <head>
    <title>XHTML</title>
  </head>
  <body>
    <p>Hello XHTML</p>
  </body>
</html>

ブラウザで http://xx.xx.xx.xx/hello.html にアクセスし、ページが見れればOK。