有两年多没有使用resin了,最近打算在机器上安装一个web container跑点java web app,同时也可能需要支持php,原本打算用apache + tomcat,apache可以加载php模块来提供php支持,tomcat作为java web container。但突然想到resin,似乎是可以直接支持php的,而且resin的速度也是稍微快于tomcat,于是跑到resin的官网看了一下,恩,新出了4.0版本(惭愧,两年前用的是3.0或者3.1)。
再看目标路径/usr/local/java/jdk1.6,没有问题。有点郁闷,莫名其妙,于是找到resin官网的说明文档resininstallation quick start,发现一句话,"On Unix, set the JAVA_HOME variable or link /usr/java to the java home."。 好吧,试试/usr/java这个办法,
ln -s /usr/local/java/jdk1.6 /usr/java
再执行configure就不再出错了(补充,这个问题只在ubuntu 9.10出现,后来在suse sles11上没有出现,sles只要JAVA_HOME正确就可以了),接着
make
make install
****************************************************************
WARNING: Unable to install /etc/init.d/resin
Destination is not writable. Usually, only root has
permissions to install this file.
This file is not required, but is used to start Resin
at boot time.
****************************************************************
启动resin,然后用浏览器访问http://192.168.0.40:8080/,成功。
cd bin
./resin.sh start
试着直接使用/etc/init.d/resin来启动resin,模拟开机时的系统调用:
./resin start
./resin: line 86: log_daemon_msg: command not found
./resin: line 96: log_end_msg: command not found
意外发现上面的错误提示,打开/etc/init.d/resin,以下是启动的脚本片段:
log_daemon_msg "Starting resin"
if test -r /lib/lsb/init-functions; then
. /lib/lsb/init-functions
else
log_daemon_msg () {
if [ -z "$1" ]; then
return 1
fi
return 1
fi
if [ -z "$2" ]; then
echo -n "$1:"
return
fi
echo -n "$1: $2"
}
log_end_msg () {
[ -z "$1" ] && return 1
if [ $1 -eq 0 ]; then
echo " ."
else
echo " failed!"
fi
return $1
}
fi
java.lang.IllegalArgumentException: www-data is an unknown user
at com.caucho.bootjni.JniProcess.exec(Native Method)
at com.caucho.bootjni.JniProcess.<init>(JniProcess.java:91)
at com.caucho.bootjni.JniProcess.create(JniProcess.java:124)
at com.caucho.bootjni.JniBoot.exec(JniBoot.java:69)
at com.caucho.boot.WatchdogChildProcess.createProcess(WatchdogChildProcess.java:381)
at com.caucho.boot.WatchdogChildProcess.run(WatchdogChildProcess.java:126)
at com.caucho.boot.WatchdogChildTask.run(WatchdogChildTask.java:174)
at com.caucho.util.ThreadPool$PoolThread.runTasks(ThreadPool.java:901)
at com.caucho.util.ThreadPool$PoolThread.run(ThreadPool.java:866)
怀疑是这个造成的,watch dog 启动resin时遭遇异常,因此resin没有启动,而watch dog的进程在,和ps的结果符合。实验了一下,删除所有log文件。使用/etc/init.d/resin start命令直接启动resin,成功,查看日志文件没有异常。
再次清空日志文件,重启resin,启动后ps看进程,并查看watchdog-manager.log,上面的现象重现。问题就应该在这里了,"www-data is an unknown user",用命令看了一下的确系统中不存在所谓的www-data用户,因此问题聚焦到,www-data是哪里冒出来的?很明显直接启动resin时是不会遇到这个问题的。
Unix allows only root to bind to ports below 1024. If you use Resin as your webserver
(recommended) and bind to port 80, you'll need to start Resin as root. In Resin 4.0, the
Resin process can drop privileges as soon as it's bound to all its ports. You can configure
the user that Resin uses in the <server> or <server-default> sections:
<!--
- If starting Resin as root on Unix, specify the user name
- and group name for the web server user.
-->
<resin:if test="${resin.userName == 'root'}">
<user-name>www-data</user-name>
<group-name>www-data</group-name>
</resin:if>