Debian に Apache2[2.2.3-4+etch3] をインストール

メモ:  Category:kuro_box

Debian に Apache2[2.2.3-4+etch3] をインストールします。ここでは、PHP5,MySQLのインストールを予定しているため apache2-mpm-preforkをインストールします。

PHP5とApache2の間に必要となるlibapache2-mod-php5は、apache2-mpm-preforkに依存しています。

# aptitude update
# aptitude install apache2-mpm-prefork

インストールが完了したら、とりあえずクライアントからブラウザを使って接続してみます。

ブラウザに次のように表示されれば、正常に動作しています。

It works!

apache2.confの変更

文字コードをメタタグの指定に任せるため apache2.conf を変更します。

# cd /etc/apache2/
# cp apache2.conf apache2.org
# vi apache2.conf

以下の部分を修正

AddDefaultCharset off

HTTP レスポンスヘッダに Apache バージョンを表示しないようにするため、apache2.confの 次の部分を修正します。

ServerToken Prod

Apacheが出力するフッターを抑止するよう設定します。apache2.confの 次の部分を修正します。

ServerSignature off

設定が完了したらApache2を再起動します。

/etc/init.d/apache2 restart

一般ユーザーによるドキュメントの公開

以下、作業用の一般ユーザーによりWebドキュメントを公開する場合の設定です。

Webドキュメントの管理のために管理用ユーザを作成し、そのユーザーのホームディレクトリを DocumentRootへ設定します。

ドキュメント管理ユーザーの作成

まず、管理用ユーザーを作成します。

# adduser webadmin
Adding user webadmin...
Adding new group webadmin (1001).
Adding new user webadmin (1001) with group webadmin.
Creating home directory /home/webadmin.
Copying files from /etc/skel
Enter new UNIX password: (新しいパスワードを入力)
Retype new UNIX password: (同じものをもう一度入力)
passwd: password updated successfully
Changing the user information for hoge
Enter the new value, or press return for the default
Full Name []: (無視)
Room Number []: (無視)
Work Phone []: (無視)
Home Phone []: (無視)
Other []: (無視)
Is the information correct? [y/n] y

webadminのhomeディレクトリにホームページ用のディレクトリを作成します。

# mkdir htdocs

defaultの変更

DocumentRoot等を変更します。

# cd /etc/apache2/sites-available/
# cp default default.org
# vi default

defaultファイルの以下の部分を修正します。

DocumentRoot /var/www/
↓
DocumentRoot /home/webadmin/htdocs/

<Directory /var/www/>
↓
<Directory /home/webadmin/htdocs/>

# --以下の行をコメントアウト又は削除

RedirectMatch ^/$ /apache2-default/

bluenote by BBB