<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sebthom.de &#187; virtual servers</title>
	<atom:link href="http://sebthom.de/tag/virtual-servers/feed/" rel="self" type="application/rss+xml" />
	<link>http://sebthom.de</link>
	<description>Selbständiger IT Berater - Java, J2EE, WebSphere Portal, Lotus Domino</description>
	<lastBuildDate>Sun, 20 May 2012 22:59:38 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Installing Tomcat 6 on Debian Squeeze</title>
		<link>http://sebthom.de/142-installing-tomcat-6-debian-squeeze/lang/de/</link>
		<comments>http://sebthom.de/142-installing-tomcat-6-debian-squeeze/lang/de/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 16:07:35 +0000</pubDate>
		<dc:creator>Sebastian Thomschke</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[port 80]]></category>
		<category><![CDATA[port forwarding]]></category>
		<category><![CDATA[quercus]]></category>
		<category><![CDATA[tomcat]]></category>
		<category><![CDATA[vhost]]></category>
		<category><![CDATA[virtual servers]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[xinetd]]></category>

		<guid isPermaLink="false">http://sebthom.de/?p=142</guid>
		<description><![CDATA[     <link rel="alternate" type="application/atom+xml" title="sebthom.de Category: Java" href="http://sebthom.de/category/it/development/java-coding/lang/de/feed/" />
     <link rel="alternate" type="application/atom+xml" title="sebthom.de Category: Linux" href="http://sebthom.de/category/it/linux/lang/de/feed/" />
This post describes how to setup Tomcat 6 on Debian Squeeze. The configured Tomcat serves requests on port 80 without the need of an additional web server. This is especially good for virtual servers (VPS) providing limit memory. It also has multiple virtual hosts configured, each with it&#8217;s own webapp with context root / and [...]]]></description>
			<content:encoded><![CDATA[<p>This post describes how to setup Tomcat 6 on Debian Squeeze. The configured Tomcat serves requests on port 80 without the need of an additional web server. This is especially good for virtual servers (VPS) providing limit memory. It also has multiple virtual hosts configured, each with it&#8217;s own webapp with context root / and optional support for PHP via the Quercus PHP implementation.</p>
<h3>Installing Sun Java 6</h3>
<p>Ensure the non-free section is enabled for the APT repository configuration in /etc/apt/sources.list, e.g. &#8220;deb http://ftp.de.debian.org/debian testing main contrib non-free&#8221;</p>
<pre name="code" class="php">
apt-get update
apt-get install sun-java6-jdk
echo 'JAVA_HOME="/usr/lib/jvm/java-6-sun"' >> /etc/environment
echo 'JRE_HOME="/usr/lib/jvm/java-6-sun/jre"' >> /etc/environment
</pre>
<h3>Installing Tomcat 6</h3>
<pre  name="code" class="php">
apt-get install tomcat6 tomcat6-admin
/etc/init.d/tomcat6 stop
</pre>
<h3>Creating standard Tomcat directory layout</h3>
<pre name="code" class="php">
mkdir /opt/tomcat
cd /opt/tomcat
ln -s /etc/tomcat6/ conf
ln -s /usr/share/tomcat6/bin/ bin
ln -s /usr/share/tomcat6/lib/ lib
ln -s /var/lib/tomcat6/webapps webapps
ln -s /var/log/tomcat6/ logs
</pre>
<h3>Creating a Tomcat admin user</h3>
<p>In /opt/tomcat/conf/tomcat-users.xml add an entry like:</p>
<pre name="code" class="xml">
&lt;user name="ADMIN_USERNAME" password="ADMIN_PASSWORD" roles="admin,manager" /&gt;
</pre>
<h3>Setting up virtual hosts</h3>
<p>For each virtual host execute the following command. Replace &#8220;mydomain.com&#8221; with the desired virtual host name, but omit the &#8220;www.&#8221; part.</p>
<pre name="code" class="php">
mkdir -p /opt/tomcat/webapps.mydomain.com/ROOT
</pre>
<p>In the &lt;Engine&gt; tag of &#8220;/opt/tomcat/conf/server.xml&#8221; add one host entry for each virtual host.</p>
<pre name="code" class="xml">
&lt;Host name="mydomain.com" appBase="/opt/tomcat/webapps.mydomain.com"&gt;
    &lt;Alias&gt;www.mydomain.com&gt;/Alias&gt;
    &lt;Valve className="org.apache.catalina.valves.AccessLogValve" prefix="mydomain_access_log." suffix=".txt" pattern="common"/&gt;
&lt;/Host&gt;
</pre>
<p>The &lt;Alias&gt; tag tells Tomcat to redirect from www.mydomain.com to mydomain.com.<br />
The &lt;Valve&gt; tag enables access logging in the standard logging format.</p>
<h3>Using xinetd to configure port 80 for Tomcat</h3>
<p>Binding a service on port 80 requires root permissions. Thus we use port forwarding to &#8220;bind&#8221; Tomcat to port 80. My VPS does not support the use of &#8220;iptables -j REDIRECT&#8221; therefore I am using xinetd as a web proxy.<br />
Ensure that no other service is listening on port 80/443:</p>
<pre name="code" class="php">
netstat -pan | grep ":80\|:443"
</pre>
<p>Register the required xinetd services:</p>
<pre name="code" class="php">
echo echo "
service www
{
        socket_type     = stream
        protocol        = tcp
        user            = root
        wait            = no
        bind            = 88.80.198.181
        port            = 80
        redirect        = localhost 8080
        disable         = no
        flags           = REUSE
        log_type        = FILE /var/log/wwwaccess.log
        log_on_success  -= PID HOST DURATION EXIT

        per_source      = UNLIMITED
        instances       = UNLIMITED
}

service https
{
        socket_type     = stream
        protocol        = tcp
        user            = root
        wait            = no
        bind            = 88.80.198.181
        port            = 443
        redirect        = localhost 8443
        disable         = no
        flags           = REUSE
        log_type        = FILE /var/log/httpsaccess.log
        log_on_success  -= PID HOST DURATION EXIT

        per_source      = UNLIMITED
        instances       = UNLIMITED
}
" > /etc/init.d/tomcat
/etc/init.d/xinetd restart
</pre>
<p>If you want to use a different service name, e.g. &#8220;tomcat&#8221; instead of &#8220;www&#8221; you must add this service to /var/services, e.g. &#8220;tomcat 80/tcp&#8221;<br />
In /opt/tomcat/conf/server.xml modify the &lt;Connector&gt; as follows:</p>
<pre name="code" class="xml">
&lt;Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" proxyPort="80" address="127.0.0.1" /&gt;
</pre>
<p>This binds Tomcat to localhost. It also tells Tomcat that port 80 is the proxy port which is necessary for correct URL generation.<br />
From now on the Tomcat admin applications are only accessible via localhost. You can use SSH port forwarding to still access the applications from your workstation&#8217;s web browser. E.g. if you are using <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTY</a> you can use this command line option &#8220;-L 8080:localhost:8080&#8243; to forward the server&#8217;s local 8080 port to your workstation&#8217;s local 8080 port. On your workstation&#8217;s browser you then simply enter <a href="http://localhost:8080/manager/html">http://localhost:8080/manager/html</a> and are connected to the server&#8217;s Tomcat admin application.</p>
<h3>Enabling PHP support (optional)</h3>
<p>Download <a href="http://quercus.caucho.com/">Quercus</a>.</p>
<pre name="code" class="php">
mkdir -p /opt/downloads
wget -o /opt/downloads/quercus-4.0.3.war http://caucho.com/download/quercus-4.0.3.war
</pre>
<p>Install Quercus as a shared library.</p>
<pre name="code" class="php">
unzip -j /opt/downloads/quercus-4.0.3.war \*.jar -d /opt/tomcat/lib
</pre>
<p>Enable PHP support for the virtual hosts by installing the quercus web.xml. For each virtual host execute:</p>
<pre name="code" class="php">
unzip /opt/downloads/quercus-4.0.3.war *web.xml -d /opt/tomcat/webapps.mydomain.com/ROOT
</pre>
<h3>Starting Tomcat</h3>
<pre name="code" class="php">
/etc/init.d/tomcat start
</pre>
<h3>References</h3>
<ul>
<li><a href="http://www.ibm.com/developerworks/java/library/l-secjav.html#h5">Securing Linux for Java services: The port dilemma</a>
<li><a href="http://ruleoftech.com/journal/redirecting-http-and-https-traffic-to-tomcats-ports">Redirect HTTP and HTTPS traffic to Tomcat&#8217;s ports</a>
<li><a href="http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html">Tomcat 6: Virtual Hosting How To</a>
<li><a href="http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html">Tomcat 6: Classloader How To</a>
<li><a href="http://www.ex-parrot.com/pete/tomcat-vhost.html">Virtual Hosting with Tomcat</a>
<li><a href="http://wiki.caucho.com/Quercus:_Tomcat">Quercus: Tomcat</a>
<li><a href="http://www.ubuntugeek.com/how-to-install-tomcat-6-on-ubuntu-9-04-jaunty.html">How to install Tomcat 6 on Ubuntu 9.04 (Jaunty)</a>
</ul>
 <img src="http://sebthom.de/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=142" width="1" height="1" style="display: none;" /><hr />
<p><small>&copy; sebthom for <a href="http://sebthom.de">sebthom.de</a>, 2010. |
<a href="http://sebthom.de/142-installing-tomcat-6-debian-squeeze/lang/de/">Permalink</a> |
<a href="http://sebthom.de/142-installing-tomcat-6-debian-squeeze/lang/de/#comments">8 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://sebthom.de/142-installing-tomcat-6-debian-squeeze/lang/de/&amp;title=Installing Tomcat 6 on Debian Squeeze">del.icio.us</a>
<br/>
Post tags: <a href="http://sebthom.de/tag/java/" rel="nofollow tag">Java</a>, <a href="http://sebthom.de/tag/php/" rel="nofollow tag">PHP</a>, <a href="http://sebthom.de/tag/port-80/" rel="nofollow tag">port 80</a>, <a href="http://sebthom.de/tag/port-forwarding/" rel="nofollow tag">port forwarding</a>, <a href="http://sebthom.de/tag/quercus/" rel="nofollow tag">quercus</a>, <a href="http://sebthom.de/tag/tomcat/" rel="nofollow tag">tomcat</a>, <a href="http://sebthom.de/tag/vhost/" rel="nofollow tag">vhost</a>, <a href="http://sebthom.de/tag/virtual-servers/" rel="nofollow tag">virtual servers</a>, <a href="http://sebthom.de/tag/vps/" rel="nofollow tag">VPS</a>, <a href="http://sebthom.de/tag/xinetd/" rel="nofollow tag">xinetd</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://sebthom.de/142-installing-tomcat-6-debian-squeeze/feed/lang/de/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

