Apache2 connector installation
I only installed the Apache2 Tomcat connector, since Apache2 is already installed on my server (I use it with Torrentflux):
sudo apt-get install libapache2-mod-jkI then prepared Apache workers configuration file
sudo vim /etc/apache2/workers.properties
workers.tomcat_home=/opt/tomcat
workers.java_home=/usr/lib/jvm/java-6-sun
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
And Jk module configuration file
sudo vim /etc/apache2/conf.d/jk.conf
<ifmodule mod_jk.c>and at last restarted Apache2 and Tomcat
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel error
</ifmodule>
sudo /etc/init.d/apache2 stopVirtual host configuration
sudo /etc/init.d/tomcat restart
sudo /etc/init.d/apache2 start
I created virtual host directories
sudo mkdir /var/www/tomcatthen I created Apache2 virtual host file. My computer has two network cards installed in it, I so decided to tie Tomcat virtual host the the second one.
sudo mkdir /var/www/tomcat/htdocs
sudo mkdir /var/www/tomcat/logs
sudo vim /etc/apache2/sites-available/tomcat
<virtualhost 192.168.30.101>then I enabled it:
JkMount /*.jsp default
ServerName tomcat.local
ServerAdmin xxx@tomcat.local
DocumentRoot /var/www/tomcat/htdocs
ErrorLog /var/www/tomcat/logs/error.log
CustomLog /var/www/tomcat/logs/access.log common
<directory /var/www/tomcat/htdocs>
Options -Indexes
</directory>
</virtualhost>
a2ensite tomcatthen I configured virtual host on Tomcat side too editing tomcat configuration file
/etc/init.d/apache2 reload
vim /opt/tomcat/conf/server.xmland adding this just after the default host section
...I restarted tomcat
<!-- tomcat.local -->
<host name="tomcat.local" appBase="/var/www/tomcat"
unpackWARs="true" autoDeploy="true">
<context path="" docBase="htdocs" debug="0" reloadable="true"/>
<valve className="org.apache.catalina.valves.AccessLogValve"
directory="/var/www/tomcat/logs" prefix="tomcat_access_" suffix=".log"
pattern="common" resolveHosts="false"/>
</host>
<!-- END tomcat.local -->
...
/etc/init.d/tomcat restartand, at last, I wrote a simple jsp page to verify everthing is working
sudo vim /opt/tomcat/webapps/test/test.jsp
<html>
<head>
<title>Tomcat virtual host</title>
</head>
<body>
<h1>Apache Tomcat virtual host is working</h1>
Today is: < %= new java.util.Date().toString() %>
</body>
</html>
No comments :
Post a Comment