バーチャルホストを追加するごとに、個別にcgiの実効権限などを設定してきたが、今後バーチャルホストを増やす前提で運用するため、一々そのたびに実効設定をするのが面倒。そこで、ユーザーディレクトリの公開領域全体にcgiの実効許可をあらかじめ行う。
ユーザーディレクトリは
/home/hoge
公開領域は
/home/hoge/public_html
に設定するため、今後作成される
/home/*/public_html
にはすべてcgiの実効許可を与える。
apache2の諸々の設定ファイルは
/etc/apache2/mods-available/
以下に集まっている。ユーザーディレクトリの設定を行うファイルは
userdir.conf
に書かれている。
ubuntu8.04 LTS版のuserdir.confの初期状態は
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>
</IfModule>
と書かれている。
この<Dirctory> </Dircotry>を書き換える。
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root<Directory /home/*/public_html>
Addhandler cgi-script .cgi
Addhandler cgi-script .pl
AllowOverride all
Options ExecCGI FollowSymLinks
Order allow,deny
Allow from all
</Directory></IfModule>
ここで保存。
userdir.confを有効化
sudo a2enmod
Which module would you like to enable?
Your choices are: -設定されているモジュール名すべてが表示される-
Module name? userdir
Module userdir installed; run /etc/init.d/apache2 force-reload to enable.
先日設定した、バーチャルホストの設定ファイルから、<Directories></Directories>の設定をコメントアウトしてテストする。
NameVirtualHost 192.168.0.29:80
<VirtualHost 192.168.0.29:80>
ServerName west-tokyo.ddo.jp
DocumentRoot /home/nick/public_html/
#<Directory /home/*/public_html>
# Addhandler cgi-script .cgi
# Addhandler cgi-script .pl
# AllowOverride all
# Options ExecCGI FollowSymLinks
# Order allow,deny
# Allow from all
#</Directory>
CustomLog /var/log/west-tokyo/access.log env=!no
ErrorLog /var/log/west-tokyo/error.log
</VirtualHost><VirtualHost 192.168.0.29:80>
ServerName www.west-tokyo.net
DocumentRoot /home/west-tokyo/public_html/
#<Directory /home/*/public_html>
# Addhandler cgi-script .cgi
# Addhandler cgi-script .pl
# AllowOverride all
# Options ExecCGI FollowSymLinks
# Order allow,deny
# Allow from all
#</Directory>
CustomLog /var/log/west-tokyo/access.log env=!no
ErrorLog /var/log/west-tokyo/error.log
</VirtualHost><VirtualHost 192.168.0.29:80>
ServerName mt5.west-tokyo.net
DocumentRoot /home/west-tokyo/public_html/mt5/
#<Directory /home/*/public_html>
# Addhandler cgi-script .cgi
# Addhandler cgi-script .pl
# AllowOverride all
# Options ExecCGI FollowSymLinks
# Order allow,deny
# Allow from all
#</Directory>
CustomLog /var/log/west-tokyo/access.log env=!no
ErrorLog /var/log/west-tokyo/error.log
</VirtualHost>
Apache2の再読み込み。
nick@ubuntu:/etc/apache2/mods-available$ sudo /etc/init.d/apache2 force-reload
* Reloading web server config apache2 [ OK ]
ここで、任意のcgiスクリプトをバーチャルホストで設定したドメインで実行。動作していれば、設定完了です。今後は、新たにバーチャルホストを設定する際に、<Directories></Directories>の設定をする必要はありません。









