Tomcat

From campisano.org
Jump to navigation Jump to search

Using apt-get

Install

apt-get install apache2 tomcat6 libapache-mod-jk

Configure

  • nano /etc/apache2/mods-enabled/jk.conf
<IfModule mod_jk.c>
    JkWorkersFile /etc/apache2/workers.properties
    JkShmFile     /var/log/apache2/mod_jk.shm
    JkLogFile     /var/log/apache2/mod_jk.log
    JkLogLevel    warn
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    JkOptions     +ForwardKeySize +ForwardURIProxy -ForwardDirectories
</IfModule>
  • nano /etc/apache2/workers.properties
ps=/
worker.list=tomcat6
worker.tomcat6.port=8009
worker.tomcat6.host=localhost
worker.tomcat6.type=ajp13
worker.tomcat6.lbfactor=1
  • nano /etc/apache2/sites-available/default
<VirtualHost *:80>
[...]
    <IfModule mod_jk.c>
        JkMount /YOUR_APP tomcat6
        JkMount /YOUR_APP/ tomcat6
        JkMount /YOUR_APP/* tomcat6
    </IfModule>
  • nano /etc/tomcat6/server.xml
#### uncomment follow line
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Start

service tomcat6 restart
a2enmod jk
service apache2 restart

Manual install

outlaw:~# apt-get install openjdk-6-jdk
root@host:~# tar -xzf apache-tomcat-7.0.4.tar.gz
root@host:~# export CATALINA_HOME=/usr/local/tomcat
root@host:~# mv apache-tomcat-7.0.4 $CATALINA_HOME
root@host:~# groupadd -g 5002 tomcat
root@host:~# useradd -g 5002 -u 5002 -d $CATALINA_HOME tomcat
root@host:~# chown -R tomcat:tomcat $CATALINA_HOME

To test

root@host:~# su - tomcat
tomcat@host:~$ export CATALINA_HOME=/usr/local/tomcat
tomcat@host:~$ export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
tomcat@host:~$ $CATALINA_HOME/bin/startup.sh #olhar em localhost:8080
tomcat@host:~$ $CATALINA_HOME/bin/shutdown.sh
tomcat@host:~$ exit

Tomcat Connectors to Apache web server

	
root@host:~# wget http://linorg.usp.br/apache/tomcat/tomcat-connectors/jk/source/jk-1.2.30/tomcat-connectors-1.2.30-src.tar.gz
root@host:~# tar -xzf tomcat-connectors-1.2.30-src.tar.gz
root@host:~# cd tomcat-connectors-1.2.30-src/native/
root@host:~# ./configure --with-apxs=/usr/local/apache/bin/apxs
root@host:~# make
root@host:~# make install