garbagetown

個人の日記です

Redmine (3)

passenger で動くようになった redminehttp://redmine.yourdomain.org/ みたいなカッコいい URL でアクセスしたいので、バーチャルホストの設定をします。*1

バーチャルホストの設定

モジュールの有効化のときと同様に、ubuntu の流儀に従い /etc/apache2/sites-available に設定ファイルを作成する。

$ cd /etc/apache2/sites-available
$ sudo vi redmine.yourdomain.org
<VirtualHost *:80>
   ServerName redmine.yourdomain.org
   DocumentRoot /var/lib/redmine-0.8.3/public/
</VirtualHost>

設定ファイルを作成したら /etc/apache2/sites-enabled からリンクを貼って apache を再起動。

$ cd ../sites-enabled/
$ sudo ln -s ../sites-available/redmine.yourdomain.org redmine.yourdomain.org

$ ls -la
total 8
drwxr-xr-x 2 root root 4096 2009-04-25 12:00 .
drwxr-xr-x 7 root root 4096 2009-02-01 23:19 ..
lrwxrwxrwx 1 root root   26 2009-01-11 15:22 000-default -> ../sites-available/default
lrwxrwxrwx 1 root root   42 2009-04-25 12:00 redmine.yourdomain.org -> ../sites-available/redmine.yourdomain.org

$ sudo /etc/init.d/apache2 restart
 ... waiting    ...done.

再起動後にブラウザから http://redmine.yourdomain.org/ にアクセスしたら、忌まわしき 500 Internal Server Error が発生。何故だ。

mod_rewrite の有効化

慌てず騒がずログを確認。mod_rewrite が実行できていなかった。そう言えばインストールした記憶も有効化した記憶も無い。

$ vi /var/log/apache2/error.log
[Sat Apr 25 12:33:24 2009] [alert] [client xxx.xxx.xxx.xxx] 
/var/lib/redmine-0.8.3/public/.htaccess: Invalid command 'RewriteEngine', perhaps 
misspelled or defined by a module not included in the server configuration

/etc/apache2/mods-available の中を確認したところ、mod_rewrite はインストール済みだったので、a2enmod で有効化して apache を再起動。

$ cd /etc/apache2/mods-available
$ ls rewrite*
rewrite.load

$ sudo a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!

$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2
 ... waiting    ...done.

再起動後、ブラウザから再度 http://redmine.yourdomain.org/ にアクセスしたら今度は 404 Not Found が発生。何故だ。

Directory ディレクティブ

が足りなかったっぽい。兄貴の嘘つき。

$ sudo vi redmine.yourdomain.org
<VirtualHost *:80>
   ServerName redmine.yourdomain.org
   DocumentRoot /var/lib/redmine-0.8.3/public/
   <Directory redmine.yourdomain.org>
      Options FollowSymLinks
      AllowOverride None
   </Directory>
</VirtualHost>

$ sudo /etc/init.d/apache2 restart
 ... waiting    ...done.

できた。何度書いても apache の設定はよく分からない。

*1:アクセスするホスト名を yourdomain.org とした場合。万が一、参考にされる場合は適宜読み替えてください。