サービスご利用中のお客さま

VPSならラピッドサイト。VPS(仮想専用サーバー)販売14年の実績!

01) httpd.conf

httpd.conf

VPSサービスのWEBサーバーはApacheで構成されています。

お客さまのアカウントごとに独立した設計でApacheがインストールされていますので、
お客さま独自の設定でApacheをカスタマイズすることが可能です。

httpd.conf(Apacheの設定ファイル)はテキスト形式で構成され、
その一行一行の記述内容でApacheの挙動を制御します。

httpd.confのパス

[root@linux conf]# pwd
/etc/httpd/conf

[root@linux conf]# ls -al
total 84
drwxr-xr-x 6 root root 4096 May 22 18:26 .
drwxr-xr-x 4 root root 4096 Apr 29 14:43 ..
lrwxrwxrwx 1 root root 37 Dec 22 07:19 Makefile -> ../../../usr/share/ssl/certs/Makefile
-rw-r--r-- 1 root root 38759 May 16 12:25 httpd.conf
-rw-r--r-- 1 root root 12959 Oct 12 2006 magic
lrwxrwxrwx 1 root root 15 Dec 22 07:19 mime.types -> /etc/mime.types
drwx------ 2 root root 4096 Oct 12 2006 ssl.crl
drwx------ 2 root root 4096 May 16 12:00 ssl.crt
drwx------ 2 root root 4096 May 16 11:42 ssl.csr
drwx------ 2 root root 4096 May 16 12:28 ssl.key
drwx------ 2 root root 4096 Oct 12 2006 ssl.prm

httpd.confのバックアップ

[root@linux conf]# cp httpd.conf httpd.conf.20070521

例1)ドキュメントルートを変更する

このページの内容は、サーバーやshellアクセス等の知識・スキルをお持ちの方を対象とした参考情報となります。
特にドキュメントルートの変更は、他のアプリケーション等にも影響する場合がございます。
ドキュメントルートを変更された場合には、動作保障外、サポート対象外とさせていただいておりますので予めご了承ください。
該当箇所
【変更前】
DocumentRoot "/var/www/html"

【変更後】
# DocumentRoot "/var/www/html"
DocumentRoot "/home/webadmin/public_html"
ディレクトリーを作成
[root@linux conf]# mkdir -p /home/webadmin/public_html
[root@linux conf]# chown -R webadmin:webadmin /home/webadmin/public_html

例2)mod_userdir

"mod_userdir"を利用することで"/home/*/www"以下に設置したコンテンツにアクセスできるようになります。

ドメイン移転前やDNS切替前にアップロードしたコンテンツを確認する際に有効です。

mod_userdirの設定

Webサーバーの設定ファイル httpd.conf にてmod_userdir の設定を行います。
httpd.confは重要な設定ファイルですので、作業前に必ずバックアップ(コピー)をとってください。

以下の2箇所を編集します。

【変更前】

# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disable

【変更後】

# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disable
UserDir /home/*/www
ScriptAliasMatch /~(.*)/cgi-bin(.*) "/home/$1/www/cgi-bin$2"
UserDir enabled USERNAME

※特定のサブホストにのみ設定をしたい場合は、「USERNAME」の部分に
  該当のサブホストのユーザーID(サブホストのドメイン管理者)を記述します。
  複数のユーザーIDを記述する場合は、半角スペースで区切って列記します。
※すべてのサブホストに設定をしたい場合は、「USERNAME」の部分に *(アスタリスク)を記述します。

上記編集後、Webサーバー(Apache)を再起動することで設定が反映されます。
Apacheの再起動のコマンドは以下のとおりです。
# restart_apache



例3)mod_rewrite

"mod_rewrite"はWEBサーバーへのアクセスを異なるURLにリダイレクトします。

http://www.rapidsite.jp/ → http://www.rapidsite.jp/eccube/html/index.php

ドメイン名のURLへのアクセスを標準搭載アプリケーションの公開URLへリダイレクトするなどの用途に使います。
変更箇所
【変更前】
# default virtual hosts
<VirtualHost 124.40.2.233:80>
SSLEngine off
</VirtualHost>

【変更後】
# default virtual hosts
<VirtualHost 124.40.2.233:80>
SSLEngine off
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/$ /eccube/html/ [R]
RewriteOptions inherit
</IfModule>

</VirtualHost>

Apacheの再起動

httpd.confを編集して設定を反映させるにはApacheの再起動が必要です。

[root@linux conf]# restart_apache

参考



ページの先頭へ戻る