HostJava.net FAQ
From HostJava.net
Private Tomcat
What is Tomcat?
"Tomcat is a free, open-source implementation of Java Servlet and JavaServer Pages technologies developed under the Jakarta project at the Apache Software Foundation. Tomcat is available for commercial use under the ASF license from the Apache web site in both binary and source versions."
503 Service Temporarily Unavailable
'503 Service Temporarily Unavailable' usually means your tomcat is down. Please login by ssh and start it as described in the welcome email. You can browse logs/catalina.out for possible reason
Aapche Mappings
Your Tomcat cooperates with the Apache webserver, which is not administered by the user, but the system administrator. By default, your Tomcat is pointed to webapps/ROOT
Your default mappings for Apache are:
/*.jsp /*.do /*.action /servlet/* /admin/* /admin /manager/* /manager /jsp-examples/* /servlets-examples/* /WEB-INF/*
If you wish us to add additional mappings, just let us know by emailing support@hostjava.net or loging into billing/support system at https://support.hostjava.net/
Are there shortcut commands for Tomcat start up and shutdown?
To start/stop/restart tomcat you can also use shortcut commands:
- to kill java:
$ jk
- to start it:
$ js
- to restart it:
$ jr
or full commands:
$ cd
and then to start:
$ jakarta-tomcat/bin/startup.sh
to stop:
$ killall -9 java
to list running processes (including java):
$ ps x
How do I list all running processes?
You can also list all running processes (including Java) using:
ps x
RMI (Remote Method Invocation)
RMI (Remote Method Invocation) is not permitted on shared servers due to our inability to monitor ports and behaviour of the object and accounting for shared resources usage. As such, we can provide this service on a dedicated server.
Tomcat Time zone
This is shared hosting and system time cannot be changed.
You can set TZ variable in your environment with
export TZ=GMT
in your ~/.bashrc file (create if necessary) and for tomcat with
CATALINA_OPTS=-Duser.timezone=GMT
(edit jakarta-tomcat/bin/catalina.sh)
The latter may not be necessary.
MySQL:
To retrieve dates in another timezone from database see CONVERT_TZ at http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
Postgresql:
Use timestamp with timezone type. See http://www.postgresql.org/docs/8.0/static/datatype-datetime.html
Setting TZ may be enough.
After setting TZ, relogin and run
echo $TZ
to check current timezone, then run
date
to check current time and finally restart the tomcat.
How can I access Tomcat manager/admin?
To access Tomcat manager/admin you need tweak configuration file (jakarta-tomcat/conf/tomcat-users.xml). For this please execute fallowing commands (please change password):
cd cd jakarta-tomcat
cat>conf/tomcat-users.xml<<EOF <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="manager"/> <role rolename="admin"/> <user username="admin" password="mysecret5" roles="admin,manager"/> </tomcat-users> EOF
killall -9 java
jk
You are done. You can access Manager from URL: http://yourdomain.com/manager/html
How to create a WAR file?
1. Log in to your account. We recommend that you use Putty for SSH2 access.
$ cd
2. Go to directory
$ cd jakarta-tomcat/webapps/testapp
3. Use the java archive command 'jar'
$ jar -cvf testapp.war *
How do I override the default home page loaded by Tomcat?
With Private/Premium Tomcat, you usually test it by loading [WWW] http://yourdomain.com (If you requested mapping /* for your domain). The contents of that page are compiled into the index_jsp servlet. The page even warns against modifying the index.jsp files for this reason. Luckily, it is quite easy to override that page. Inside $TOMCAT_HOME/conf/web.xml there is a section called <welcome-file-list> and it looks like this:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
The default servlet attempts to load the index.* files in the order listed. You may easily override the index.jsp file by creating an index.html file at $TOMCAT_HOME/webapps/ROOT. It's somewhat common for that file to contain a new static home page or a redirect to a servlet's main page. A redirect would look like:
<html>
<head>
<meta http-equiv="refresh" content="0; URL=http://mydomain.com/servlet/">
</head>
<body>
</body>
</html>
This change takes effect immediately and does not require a restart of Tomcat.
How to avoid listing files under jsp directory on Tomcat?
In Tomcat 4.x and upper versions, the Default Servlet serves static content. The Tomcat Functional Specifications require that implementations accept several parameters--including one that indicates whether to provide directory listings when a directory without welcome files is requested.
To suppress directory listings in Tomcat, set the value of the servlet's initialization parameter listings to false in Tomcat's default deployment descriptor ($CATALINA_HOME/conf/web.xml). Below is Tomcat's default definition for the default servlet with directory listings disabled:
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
How can I connect to mysql database using JDBC?
With Private Tomcat please edit your $CATALINA_HOME/conf/server.xml file and append this lines.
// loads the JDBC driver
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
// get a database connection
Connection conn = DriverManager.getConnection(
"jdbc:mysql://hostname/databaseName",
"user",
"password");
obviously the JDBC driver "org.gjt.mm.mysql.Driver" must be in classpath. You can download it from http://dev.mysql.com/downloads/connector/j/5.1.html
How do I set session timeouts of greater than 30 minutes?
Tomcat session keeps expiring in spite of entries in $CATALINA_HOME/conf/web.xml to the effect of
<session-config>
<session-timeout>60</session-timeout>
</session-config>
(where the number indicates the time in minutes)
Does Tomcat support JMS (Java Messaging Service)?
Tomcat is just a servlet container, not an EJB container nor an application server, so it does not contains any JMS basic support.
Can I share jar/libs between other application?
Sure you can. To share libraries between applications only you should use:
$CATALINA_HOME/common/lib
NotFoundException: com.mysql.jdbc.Driver
Please download JDBC connector (mysql-connector-java-[version]-bin.jar) into $CATALINA_HOME/common/lib directory and restart Tomcat.
How can I configure Tomcat with multiple virtual hosts?
With Private Tomcat you have full control over configuration files. I will show you a little example.
You have 2 or more domains. As I said this is a little example so we will use only 2 domains such like domain1.com and domain2.com.
Our /psahome/domain1.com/jakarta-tomcat/webapps directory:
$ls -al docs domain1 domain2 examples manager host-manager ROOT
Please put JSP files in to domain1 and domain2 directory.
- 1. Domain1.com is the main domain (the main domain can point do different directory such as ROOT, anyway this is just only example).
- 2. Domain2.com is domain that we want to add to Tomcat.
- 3. You need create domain2.com under Plesk Control Panel.
- 4. Please change name srevers for domain2.com.
- 5. Please email support@hostjava.net to create mapping for domain2.com:
"Please create mapping /* for domain domain2.com"
- 6. Next you need configure $CATALINA_HOME/conf/server.xml file.
Please edit $CATALINA_HOME/conf/server.xml
<Host name="domain1.com" debug="0" appBase="webapps" unpackWARs="true"> <Alias>www.domain1.com</Alias> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="virtual_log1." suffix=".log" timestamp="true"/> <Context path="" docBase="/psahome/domain1.com/jakarta-tomcat/webapps/domain1" debug="0" reloadable="true"/> </Host>
<Host name="domain2.com" debug="0" appBase="webapps" unpackWARs="true"> <Alias>www.domain2.com</Alias> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="virtual_log2." suffix=".log" timestamp="true"/> <Context path="" docBase="/psahome/domain2.com/jakarta-tomcat/webapps/domain2" debug="0" reloadable="true"/> </Host>
- 7. Please restart Tomcat.
How can I configure Tomcat with sub domain?
The procedure is similar as described above but have some differences.
- Please add sub domain in Plesk Control Panel.
- Please email support@hostjava.net to create mapping for subdomainname.domain.com:
"Please create mapping /* for subdomainname.domain.com"
- Put your files to $CATALINA_HOME/webapps/subdomainname
- Configure $CATALINA_HOME/conf/server.xml file
<Host name="subdomainname.domain.com" debug="0" appBase="webapps" unpackWARs="true"> <Alias>www.subdomainname.domain.com</Alias> <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="virtual_log2." suffix=".log" timestamp="true"/> <Context path="" docBase="/psahome/domain2.com/jakarta-tomcat/webapps/subdomainname" debug="0" reloadable="true"/> </Host>
- Please restart Tomcat.
If something doesn't work as it shuld be check the $CATALINA_HOME/logs/catalina.out file.
What is the best method for changing the JDK version from 1.4 to 1.6?
Version Location (path)
JDK 1.4.2: /usr/local/jdk1.4.2
JDK 1.5.0: /usr/local/jdk1.5.0
JDK 1.6.0: /usr/local/jdk1.6.0
Please login to your account and edit $CATALINA_HOME/jakarta-tomcat/bin/catalina.sh file.
cd vi jakarta-tomcat/bin/catalina.sh
change JAVA_HOME from:
JAVA_HOME=/usr/local/jdk1.4.2
to
JAVA_HOME=/usr/local/jdk1.6.0
- Please don't forget to restart Tomcat.
Can I send email with JavaMail and Tomcat?
Here is small example. Source code:
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
String host = "mail.domainname.com";
String user = "user@domain.com";
String pass = "xxxxx";
String to = "user@example.com";
String from = "user@domain.com";
String subject = "Test subject";
String messageText = "Test body";
boolean sessionDebug = false;
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, pass);
transport.sendMessage(msg, msg.getAllRecipients());
transport.close();
%>
- Create directory javamail
cd jakarata-tomcat/webapps mkdir javamail
- Please download war file from http://download.hostjava.net/javamail.war.
wget http://download.hostjava.net/javamail.war
- Unzip
cd jakarata-tomcat/webapps/javamail unzip -x javamail.war
- Please modify host, user, pass, to, from variables.
- Please email support@hostjava.net to create mapping for domain if mapping already is /* you don't need email us:
"Please create mapping /javamail/* for domain domain.com"
- Restart Tomcat.
- You can check JavaMail by executing URL
http://yourdomain.com/javamail/mail.jsp
org.apache.jasper.JasperException: Unable to compile class for JSP (Permission denied)
Please go to your home directory and execute the command:
cd rm -Rf jakarta-tomcat/work
java.net.BindException: Address already in use:8080
Please check how many java processes are you using if more that one you need kill them and start Tomcat.
- We see 2 processes runing.
ps x 3410 ? Sl 0:44 /usr/local/jdk1.5.0/bin/java -Djava.awt.headless=true 7262 pts/15 Sl 1:22 /usr/local/jdk1.5.0/bin/java -Djava.awt.headless=true
- To kill above processes use command:
killall -9 java
- To start Tomcat use command:
js
Can we deploy EAR in Tomcat?
No, Tomcat doesn't support EAR files since it is only a web container. You need an EJB container in order to deploy an EAR. JBOSS works well with Tomcat (it has a version with embedded Tomcat too). JBOSS has a 'deploy' directory where you can place your EAR and that's it.
How can I change Tomcat version?
You can change tomcat by executing fallowing command from ssh:
For example to install Jakarta-Tomcat 6 execute:
changetomcat 6
Usage: /usr/local/bin/changetomcat [OPTION]
Options:
4 To install Apache-Tomcat 4
5 To install Apache-Tomcat 5.5
6 To install Apache-Tomcat 6
I broke my configuration can I restore Jakarta-Tomcat to default?
Yes, you can restore it to default by executing changetomcat command.
Example:
If you have Jakarta-Tomcat 6 and you want restore it do defaults please run:
changetomcat 6
Backup of old Jakarta-Tomcat will be stored in your private directory
ls -al private/ apache-tomcat-6.0.16-backup-DATE
What java.lang.UnsupportedClassVersionError: Bad version number in .class file error means?
Make sure that your application/classes are compiled with a JDK version lower or equal to the JDK your tomcat is running with or upgrade JDK for your tomcat.
Version numbers are as follows:
JDK 1.1 = 45.3
JDK 1.2 = 46.0
JDK 1.3 = 47.0
JDK 1.4 = 48.0
JDK 1.5 = 49.0
JDK 1.6 = 50.0
You can check what JDK was used to compile your class file by running
javap -verbose MyClassFile | head
or
hexdump -e '1/1 "%3d"' -n 2 -s 6 MyClassFile.class
To see what JDK is used by your tomcat run
grep JAVA_HOME=/ ~/jakarta-tomcat/bin/catalina.sh
or
ps x | grep java
You can change JDK for your tomcat by editing JAVA_HOME variable in jakarta-tomcat/bin/catalina.sh file.
Currently you can set JAVA_HOME to one of the below:
/usr/local/jdk1.4.2 /usr/local/jdk1.5.0 /usr/local/jdk1.6.0
Restart the tomcat for the change to take effect.
If you also need to change JDK settings for your shell, edit (create if nescessary) ~/.bashrc file and put there similar code (with your desired JDK path):
export PATH=/usr/local/jdk1.5.0/bin:$PATH export JAVA_HOME=/usr/local/jdk1.5.0
Relogin for the change to take effect.
Shared Tomcat
How do I restart shared Tomcat?
You can restart shared Tomcat (Tomcat container shared between many users) by loggin in via SSH to your account and running the following command:
$ restartsharedtomcat55
Upon running of this command our system will schedule the Tomcat restart. There is a guaranteed time of 60 minutes between each restart.
Deployment under Shared Tomcat
To deploy a web application under Shared Tomcat:
1a. Upload your application or war file to httpdocs using a FTP client software
1b. Unpack the war if necessary: login by ssh and run
cd httpdocs unzip -x mywar.war
2. Place the application files directly in httpdocs directory
3. Request Shared Tomcat restart using
restartsharedtomcat55
command after logging in via SSH.
If you are not sure that your applciation is working properly please check WEB-INF/web.xml file for any missing library or bad paths. If you think that our environment is not working as it should. Please download sample application from: http://tomcat.apache.org/tomcat-5.5-doc/appdev/sample/sample.war
1) Download sample application
Please login by SSH to server and download sample.war file.
cd mkdir private/httpdocs_backup cd httpdocs mv * ../private/httpdocs_backup cd cd httpdocs wget http://tomcat.apache.org/tomcat-5.5-doc/appdev/sample/sample.war unzip -x sample.war
2) Create mapping for application
Please use here Apache Mapping Tool:
http://wiki.hostjava.net/index.php/HostJava.net_FAQ#Apache_Mapping_.28mod_jk.29_Tool
Login by ssh to server and execute:
updatevhost domainname.com
and append line:
JkMount /hello/* wYOUR_PORT JkMount /hello wYOUR_PORT
and restart tomcat.
restartsharedtomcat55
3) JSP/SERVLET
JSP - access your jsp website by entering URL http://domainname.com/
SERVLET - access your servlet by entering URL http://domainname.com/hello
If sample application is not working Please contact us.
How many WEBAPPs can I deploy under Shared Tomcat package?
Shared Tomcat package allows you to host unlimited domains, but you can only have 1 context (web application). Document base for this context is by default set to your httpdocs directory, but can be changed on request. Upgrade to Private Tomcat if you need to host more than 1 web application.
Can I read Shared Tomcat's logs?
Yes, you can check logs. You can use tail command to accomplish this task. From ssh execute:
tail -100 /home/tomcat5/jakarta-tomcat/logs/catalina.out
Where can I put Realm tags? File server.xml doesn't exist
With Shared Tomcat access to server.xml file is restricted. Only support staff can add Realm (for example JDBC Realm)to server.xml file.
for MySQL:
<Resource name="jdbc/DB_NAME" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/DB_NAME"> <parameter> <name>username</name> <value>USER</value> </parameter> <parameter> <name>password</name> <value>PASSWORD</value> </parameter> <parameter> <name>driverClassName</name> <value>com.mysql.jdbc.Driver</value> </parameter> <parameter> <name>url</name> <value>jdbc:mysql://localhost/DB_NAME?autoReconnect=true</value> </parameter> <parameter> <name>removeAbandoned</name> <value>true</value> </parameter> <parameter> <name>removeAbandonedTimeout</name> <value>60</value> </parameter> <parameter> <name>logAbandoned</name> <value>true</value> </parameter> <parameter> <name>maxActive</name> <value>10</value> </parameter> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <parameter> <name>maxWait</name> <value>10000</value> </parameter> </ResourceParams>
Do you offer MS SQL Database?
Yes, we do offer MS SQL Database hosting. Price is $10 / 500 MB disk space with each additional 500 MB can be purchased at $10.
Apache Mapping (mod_jk) Tool
To save your time and give you more control over the apache/tomcat service we introduced another tool 'updatevhost' that will allow you to manage apache/tomcat (mod_jk) mappings and directory index file setting for your domains. See the below examples.
We recommend that you use Putty for SSH2 access.
http://www.chiark.greenend.org.uk/~sgtatham/putty/
You can also use any other commercial software package.
Definition:
Primary domain/alias - the domain or alias that the package was first setup for.
It is shown it the 'welcome' email that was sent to you after the account has been created.
Scenario 1: New web application
You have added a new java/jsp application in jakarta-tomcat/webapps/MyApp1
and you want to pass all requests matching http://domain1.com/MyApp1/* to your tomcat.
Login as primary domain's ssh user and run:
$ updatevhost domain1.com
Editor opens, please read instructions given there.
You can then add the following lines:
JkMount /MyApp1 wXXXX JkMount /MyApp1/* wXXXX
where XXXX is your tomcat AJP port mentioned in the header of the file being edited.
Save the file with F2 key.
Scenario 2: New domain
You have just added another domain domain2.com to your account and you want all HTTP and HTTPS requests
for this domain to be passed to your tomcat.
Login as primary domain's ssh user and run:
$ updatevhost domain2.com
Editor opens, please read instructions given there.
You can remove all the Jk* lines and add:
JkMount /* wXXXX
where XXXX is your tomcat AJP port mentioned in the header of the file being edited.
Save the file with F2 key.
Then do the same for HTTPS with:
$ updatevhost --ssl domain2.com
Scenario 3: New subdomain
You have created sub1.domain2.com and want it to be fully mapped to your tomcat.
Login as primary domain's ssh user and run:
$ updatevhost sub1.domain2.com
Editor opens, please read instructions given there.
You can remove all the Jk* lines and add:
JkMount /* wXXXX
where XXXX is your tomcat AJP port mentioned in the header of the file being edited.
Save the file with F2 key.
Note: As this is a subdomain the mappings will also apply to connections over HTTPS protocol.
Aside from mappings setup you may want to set up virtual hosts or contexts in jakarta-tomcat/conf/server.xml (Private Tomcat).
Domains
Nameservers and danish (.dk) domains
The following two Name Servers were registered: ns3.clusterspan.net ns1.clusterspan.net
Our company's handle (ID) is: OI511-DK
Do you host .dk domains?
Yes, we are registered with the DK Hostmaster in Denmark (http://www.dk-hostmaster.dk) and can host your .dk domain.
How do I point my domain name to your servers?
When you registered your domain name, your registrar should have given you a way to set the Domain Name Servers to use. You should set them to:
Clients who have their accounts on helsinki.clusterspan.net server should use:
1st (primary): ns18.clusterspan.net (204.10.243.120) 2nd (secondary): ns19.clusterspan.net (204.10.243.121)
Clients who have their accounts on prague.clusterspan.net server should use:
1st (primary): ns20.clusterspan.net (208.86.140.80) 2nd (secondary): ns21.clusterspan.net (208.86.140.81)
I removed my domain using Plesk control panel, and then added the domain again. Why is it the domain is not working any more with Tomcat?
If you remove and add your domain, please make sure you contact us to add it to the Tomcat so that you can continue to use it.
Control Panel
Server unexpectedly closed network connection
If you get fallowing error:
From PUtty:Server unexpectedly closed network connection.
From the SSH Terminal in the Plesk Control Panel: 'Could Not Establish Connection: Connection Reset'.
These error messages tells that your IP has been blocked and you cannot connect to the server.
Most possible reason is more than 10 failed attempts during logon process.
Please email support and don't forget to supply your IP. We will remove IP immediately.
Why storage/traffic is 0 for new domain?
The quota and traffic for new domain may be set to 0 if your existing domains are using package limits. In such case decrease storage/traffic limits of one of your domains and then increase the limits for the new domain using 'Limits' icon of respective domain.
Unable to accept the template: the following limitations are exceeded.
Please click 'OK' and fill all fields when you are adding new domain. Next decrease storage/traffic limits of one of your domains and then increase the limits for the new domain using 'Limits' icon of respective domain.
How to perform PHP setup tasks, that index.php/index.jsp/index.html/index.htm is the default page
Please email us at support@hostjava.net:
Please change VirtualHost configuration to: DirectoryIndex index.php index.html index.htm index.jsp
Non-static method PMA_Config::isHttps() should not be called statically
This error occurs when you changed password for database's user not using Plesk DB Web Admin Tool. To resolve this issue you need go to Plesk and change password for this database:
Click Databases
Click Database Users
Click the user that has a password change
In the password fields, enter the new password that they’re using with MySQL
What kind of backup do you offer?
Backup is important to maintain your business, services and website continuity. Our company takes back up seriously and we maintain two levels of backup of all data. We also suggest that ALL clients maintain their own backup and recovery procedures, as our company's Level 1 and Level 2 data backup procedures are for our usage only and fees can apply in situations where clients want to retrieve data from our backup.
Level 1:
All our servers have RAID 1 configuration. Data is stored on two seperate SCSI or SAS drives on each server. In case of hard drive failure, the system will continue to operate and use the disk drive which was not affected by the failure.
Level 2:
We perform daily and weekly backups of all our systems. The backup is done to online storage devices available over internal network. Those backup devices store terabytes of data and make it possible for our staff to retrieve client's or server's data over the internal network.
Level 3:
We advise all clients to backup their data using Plesk's Backup and Restoration procedures. Full description of the options offered by Plesk is available here:
http://download1.swsoft.com/Plesk/Plesk8.4/Doc/en-US/plesk-8.4-unix-clients-guide/index.htm?fileName=15530.htm
A Flash tutorial on backup and restore can be found at http://www.parallels.com/doc/tutorials/Plesk/Plesk8.0/eu/plesk8_eu_backup.htm
For clients requiring increased redundancy and failover functionality we can offer hosting services on an additional server or hosting facility. Having two seperate accounts on seperate hardware will limit the potential down time in case of a major system failure. Contact us if you would like to add a second hosting account to ensure your business continuity.
Ruby on Rails
Can I use Ruby on Rails and Tomcat/JSP on the same domain?
Yes, some URLs can be mapped to tomcat, some left for Apache and Ruby.
553 sorry, that domain isn't in my list of allowed rcpthosts
SMTP server requires authorization. (SMTP authorization is ON). Please make sure you have authorization turned on in your email program (Outlook, Eudora, etc.).
My ISP blcoked port 25. Can I connect to SMTP in this case?
Sure you can use alternative 587 port.
Databases
How to export MySql database script?
Login to your account via SSH and run:
$ mysqldump -u dbusername -p databasename > database.sql
You will be prompted for password and your database dump will end up in database.sql file. Then you can use SCP, FTP or HTTP to send/download it.
Alternatively, login to Plesk, choose your database, click 'DB WebAdmin' button. PhpMyAdmin window will open. Choose the database in the left side menu, then 'Export' tab. There you can choose what you want to export. Check 'Save as file' and click 'Go'.
VPS
Accessing Tomcat on Port 80
Default Jakarta-Tomcat installation run on port 8080 http://example.com:8080.
There is variety options to setup Tomcat to listen on port 80:
Mod_jk.
Mod_Jk is Tomcat-Apache plug-in that handles the communication between Tomcat and Apache. Mod_jk is not so easy to use like mod_proxy_ajp is. All newer distributions comes with mod_proxy so we're going to describe configuration with mod_proxy_ajp. However if you need to use mod_jk we are ready to configure for your needs.
Apache 2.2 and mod_proxy_ajp module.
With this module we can accomplish this task without any hassle. Apache 2.2 include mod_proxy_ajp module by default. You can install Apache by executing this command:
yum install http
Next go to /etc/httpd/conf/httpd.conf and add Vhost configuration:
nano /etc/httpd/conf/httpd.conf
Scenario 1: All request go to Tomcat
<VirtualHost 222.222.222.222>
ServerName www.example.com
ServerAlias example.com
DirectoryIndex index.jsp index.php index.html
DocumentRoot /var/www/example.com/htdocs
ProxyPass / ajp://127.0.0.1:8009
</VirtualHost>
ProxyPass / ajp://127.0.0.1:8009/
When we add this line all request to http://example.com will be served from Tomcat http://example.com:8080
Scenario 2: Only certain URL go to Tomcat i.e http://example.com/myApp
<VirtualHost 222.222.222.222>
ServerName www.example.com
ServerAlias example.com
DirectoryIndex index.jsp index.php index.html
DocumentRoot /var/www/example.com/htdocs
ProxyPass /myApp ajp://127.0.0.1:8009/MyApp
</VirtualHost>
ProxyPass /myApp ajp://127.0.0.1:8009/MyApp
When we add this line all request to http://example.com/myApp will be served from Tomcat http://example.com:8080/myApp
Please note: only http://example.com/myApp will be served from Tomcat.
Lxadminand mod_proxy_ajp module.
Default web server for Lxadmin is lighthttp we need replace this server by Apache.
To do this go to Lxadmin Control Panel and switch driver to apache: Go to "HOME" and click on "Change Program" then select "Apache".
Next we need change vhost configuration. Lxadmin store apache files in /home/httpd/example.com/conf/ directory.
Edit file:
nano /home/httpd/example.com.net/conf/lxadmin.example.com
Fallow "Apache 2.2 and mod_proxy_ajp module" FAQ.
Iptables
Iptables can forward connections from 80 to 8080 port. This can be done only with Xen based VPS.




