http://search.cpan.org/perldoc?Apache2::Reload
通常、mod_perl環境で開発する場合、srcの変更毎にapacheを再起動する必要がありますが、Apache::Reload(Apache2::Reload)を使用すれば、変更モジュールを自動的に再ロードできます。
installはMP_APXSを指定しましょう
installで単純に「perl Makefile.PL 」を実行すると、apxsが見つからないというerrorが出ます。
$ perl Makefile.PL Can't find the mod_perl include dir (reason: apxs -q INCLUDEDIR didn't return a value) at /usr/local/lib/perl5/site_perl/5.10.0/i686-linux-thread-multi/Apache2/Build.pm line 2030.
そのような場合、「env MP_APXS=〜」を指定してください。
(私の場合、開発用のapache2.2を /home/~ 以下にinstallしています)
$ cd Apache-Reload-0.10 $ env MP_APXS=/home/endo/local/apache22/bin/apxs perl Makefile.PL $ make $ make test ←私の環境へinstallした際にはmake test忘れてたような... # make install
httpd.conf の設定
Apache2::Reloadは、最低、PerlModuleとPerlInitHandlerをhttpd.confに記載すれば、使用できます。
PerlModule Apache2::Reload PerlInitHandler Apache2::Reload #PerlSetVar ReloadDirectories "/home/endo/dev/test/lib" #PerlSetVar ReloadDebug On
http://search.cpan.org/perldoc?Apache2::Reload
PerlModuleとPerlInitHandler以外の仕様はcpanに記載されていますが、ReloadDirectoriesでreload対象を限定したり、ReloadDebugでreload状況をapacheのerror_logに出力できます。
ReloadDebug Onでのerror_log出力例
$tailf -f /home/endo/local/apache22/logs/error_log Apache2::Reload: Checking mtime of Apache2/Const.pm Apache2::Reload: Checking mtime of Apache2/Reload.pm Apache2::Reload: Checking mtime of Apache2/RequestUtil.pm Apache2::Reload: Checking mtime of Apache2/ServerUtil.pm
reloadに失敗するケースもあるようです
最近、Apache2::Reloadを使い始めた私の環境では発生していませんが、reloadに失敗するケースもあるようですが、次のurlを参考にするといいのかも知れません。