As reported on the my other article about Hippo Open Source CMS i will start a fresh install of tomcat 6.
If you need to do the same as me, read on this article until the end.
First thing to do is to remove the tomcat6 installation made by using aptitude.
so let’s type:
apt-get remove tomcat6 tomcat6-admin tomcat6-common
Second: since we are going to build and install Tomcat from source, we need ant, so :
apt-get install ant
will install ant, and accetp extra packages to be installed.
Download Tomcat6 from the sources indicated at the bottom of this page: http://tomcat.apache.org/download-60.cgi
I’ve downloaded it in a folder called “tomcat” in my (root) home with the following commands, but be aware of updates before using these lines
cd mkdir tomcat cd tomcat wget http://apache.hippo.nl/tomcat/tomcat-6/v6.0.36/src/apache-tomcat-6.0.36-src.tar.gz
Then uncompress it with
tar -xvzf apache-tomcat-6.0.36-src.tar.gz
This should end up with something similar:
BUILD SUCCESSFUL Total time: 14 seconds
But this is NOT my case: actually what i’ve got is:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Oh lord! also:
locate tools.jar root@server:~/tomcat/apache-tomcat-6.0.36-src#
—chat with Filippa—
root@server:~/tomcat/apache-tomcat-6.0.36-src# locate tools.jar /usr/lib/jvm/java-1.5.0-gcj-4.4/lib/tools.jar
So it looks like i have it but it is not where it is supposed to be.
At same time i’ve this ant output:
Perhaps JAVA_HOME does not point to the JDK. It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"
So first of all is to check if i have a correct installation for java and for jdk.
was missing 🙂
then i go back to ~/tomcat/apa[tab] and
root@server:~/tomcat/apache-tomcat-6.0.36-src# ant download Buildfile: /root/tomcat/apache-tomcat-6.0.36-src/build.xml build-manifests: [copy] Copying 8 files to /root/tomcat/apache-tomcat-6.0.36-src/output/manifests download: testexist: [echo] Testing for /usr/share/java/tomcat-native-1.1.23/tomcat-native.tar.gz downloadfile-2: testexist: [echo] Testing for /usr/share/java/tomcat-native-1.1.23/LICENSE downloadzip-2: proxyflags: setproxy: testexist: [echo] Testing for /usr/share/java/commons-daemon-1.0.10/commons-daemon-1.0.10.jar downloadgz-2: testexist: [echo] Testing for /usr/share/java/commons-daemon-1.0.10/commons-daemon-1.0.10-native-src.tar.gz downloadfile-2: testexist: [echo] Testing for /usr/share/java/commons-daemon-1.0.10/windows/prunmgr.exe downloadzip-2: proxyflags: setproxy: testexist: [echo] Testing for /usr/share/java/commons-pool-1.5.7-src/build.xml downloadgz-2: proxyflags: setproxy: testexist: [echo] Testing for /usr/share/java/commons-dbcp-1.3-src/build.xml downloadgz-2: build-manifests: [copy] Copying 8 files to /root/tomcat/apache-tomcat-6.0.36-src/output/manifests build-tomcat-dbcp: testexist: [echo] Testing for /usr/share/java/ecj-3.7.2/ecj-3.7.2.jar downloadfile-2: proxyflags: setproxy: testexist: [echo] Testing for /usr/share/java/nsis-2.46/makensis.exe downloadzip: BUILD SUCCESSFUL Total time: 1 second
Now let’s try to build it with
BUILD FAILED /root/tomcat/apache-tomcat-6.0.36-src/build.xml:513: Execute failed: java.io.IOException: Cannot run program "chmod": java.io.IOException: error=12, Cannot allocate memory
root@server:~/tomcat/apache-tomcat-6.0.36-src# free total used free shared buffers cached Mem: 1830748 1582248 248500 0 118344 502096 -/+ buffers/cache: 961808 868940 Swap: 1048568 132728 915840 root@server:~/tomcat/apache-tomcat-6.0.36-src#
Let’s add some memory… starting witrh 256 megs.
root@server:~# free total used free shared buffers cached Mem: 2092892 1429024 663868 0 10644 278196 -/+ buffers/cache: 1140184 952708 Swap: 1048568 0 1048568
root@server:~/tomcat/apache-tomcat-6.0.36-src# ant [blah blah] BUILD SUCCESSFUL Total time: 16 seconds
It should be in the new created dir “output”.
Now, let’s enable the mod_proxy for apache2
then let’s choose a virtualhost to thinker with and add the following lines as suggested here
<VirtualHost *:80> ServerName www.example.com ServerAlias *.example.com ProxyPreserveHost On ProxyPass / http://localhost:8080/site/ ProxyPassReverse / http://localhost:8080/site/ ProxyPassReverseCookiePath /site / </VirtualHost
and after restarting Apache, it worked, it worked that fine that is showed my ispconfig page warning me about using https. 🙂
Now i have to modify this one so it connects to a different port, let’s say 8081, so the relevant part of the virtualHost configuration file will be modified to reflect this:
ProxyPreserveHost On ProxyPass / http://localhost:8081/site/ ProxyPassReverse / http://localhost:8081/site/ ProxyPassReverseCookiePath /site /
So the Tomcat6 build took place into the /root/tomcat6/apache-tomcat[tab] and taking a look at its startup script, these files can be moved into any convenient directory.
I will stay here for a while, at least until i figure out how to move conf files into /etc/tomcat6, binaries inti /usr/local/tomcat6 , logs into /var/log/tomcat6, lib into /var/lib/tomcat and so.
But for the moment let’s see how it goes if we try to connect with tomcat. Before this, it is necessary (at least for me) to change the post specified for the connector (this case apache2) into ~/tomcat6/output/conf/server.xml, on an untoucher server.xml file, in this version, you find this param at line 69, precisely:
<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Now if have to startup the whole things:
service apache2 restart root@server:~/tomcat/apache-tomcat-6.0.36-src/output/build/bin# ./shutdown.sh Using CATALINA_BASE: /root/tomcat/apache-tomcat-6.0.36-src/output/build Using CATALINA_HOME: /root/tomcat/apache-tomcat-6.0.36-src/output/build Using CATALINA_TMPDIR: /root/tomcat/apache-tomcat-6.0.36-src/output/build/temp Using JRE_HOME: /usr Using CLASSPATH: /root/tomcat/apache-tomcat-6.0.36-src/output/build/bin/bootstrap.jar root@server:~/tomcat/apache-tomcat-6.0.36-src/output/build/bin# ./startup.sh start Using CATALINA_BASE: /root/tomcat/apache-tomcat-6.0.36-src/output/build Using CATALINA_HOME: /root/tomcat/apache-tomcat-6.0.36-src/output/build Using CATALINA_TMPDIR: /root/tomcat/apache-tomcat-6.0.36-src/output/build/temp Using JRE_HOME: /usr Using CLASSPATH: /root/tomcat/apache-tomcat-6.0.36-src/output/build/bin/bootstrap.jar root@server:~/tomcat/apache-tomcat-6.0.36-src/output/build/bin# netstat -an |grep 8081 tcp6 0 0 :::8081 :::* LISTEN
And with my browser i see:
Obviously this case there is no webapp configured yet or at least, if any by default, there are no jsp nor html files to be presented to users.
This means that now it’s time to download Hippo.. let’s find a downloadable package…
While download finishes, let’s put on a coffee.
Fine, download finished, i just discovered that this package contains tomcat as well, so i decided to use this one. To do this i changed the configuration in order to listen on port 8081 and voilà
But it looks like i have to tune the proxy part so i can access this through my normal port 80.
CONCLUSIONS in short: it requires more ram than expected. It’s not for small machines or even worst, for small VPSs. This last case regards me and my machine, at the end i had to shutdown tomcat and java to avoid to limit the memory apache2 needs to create child processes.
Cannot allocate memory: couldn't create child process:
PHP Fatal error: Out of memory (allocated 64225280) (tried to allocate 78 bytes) in /blah
unable to init Zlib: deflateInit2 returned -4: URL /index.php, referer: https://blog.giuseppeurso.net/