john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

tomcat java servlets manual install windows linux

Tomcat is a Java servlet engine (a program which provides an environment for running Java servlets)

It cannot run PHP, Perl, python, Ruby ,etc. BUT
Tomcat can serve static content such as HTML pages, images, stylesheets maybe as fast as Apache

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt-get install tomcat6

By default it will install
ubuntu tomcat5 = /usr/local/tomcat
ubuntu tomcat6 = /usr/share/tomcat6

OPENJDK will also install with the Tomcat package (otherwise you can add the Oracle Java
to your sources.list)

JAVA_HOME and JRE_HOME environment should be defined during the install

IN TOMCAT6 YOU HAVE TO SEPARATELY INSTALL THE WEBMANAGER AND EXAMPLES AND DOCS
sudo apt-get install tomcat6-admin
sudo apt-get install tomcat6-docs
sudo apt-get install tomcat6-examples

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WINDOWS

Download the installer or just the zip  http://tomcat.apache.org/

Ensure you have Java installed (x64 please!)

Windows 7:

Right click the Computer icon -> Choose Properties from the context menu

Advanced system settings -> Environment Variables -> (lower) System Variables


If the JAVA_HOME environment variable does not exist, click New.
    Variable name: JAVA_HOME
    Variable value: C:\Program Files\Java\jdk1.6.0_31

Select the PATH Variable -> Edit   (append the following string to the end)
    %JAVA_HOME%\bin

Click OK OK OK

(If you have a command prompt open you must exit it and start again)

echo %JAVA_HOME%

cd C:\Users\USERNAME\Desktop\apache-tomcat-6.0.35\bin
version.bat






- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

A web application is defined as a hierarchy of directories and files in a standard layout.

The "packed" form is known as a Web Archive, or .war file.

Unpacked it consists of directories like

/webapps/dirname=appname


  /WEB-INF/web.xml - The Web Application Deployment Descriptor


  /WEB-INF/classes/   =  JAR files.

 /WEB-INF/classes/ - This directory contains any Java class files (and associated resources)
  required for your application, including both servlet and non-servlet classes, that are not
  combined into JAR files. If your classes are organized into Java packages, you must reflect
   this in the directory hierarchy under /WEB-INF/classes/. For example, a Java class named
   com.mycompany.mypackage.MyServlet would need to be stored in a file named
   /WEB-INF/classes/com/mycompany/mypackage/MyServlet.class.

  /WEB-INF/lib/   contains required JAR files (Java class files and associated resources)
                 third party class libraries or JDBC drivers.




http://tomcat.apache.org/tomcat-6.0-doc/appdev/deployment.html

directory name  = url name = app name
username owner = tomcat-user ? or user running tomcat binary

if left in .war format tomcat will automatically decompress and deploy it
(e.g. into a directory with the app name)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TOMCAT CONTROL AND LOGS

/etc/init.d/tomcat5 start|stop
killall java


/etc/init.d/tomcat5 stop

service tomcat6 restart
service tomcat6 force-reloadcd


tail /usr/local/tomcat/logs/catalina.out
(note catalina.out logs should be rotated regularly for Production)


touch web.xml will force tomcat to reload the application

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TOMCAT CONTROL AND LOGS
/etc/tomcat6



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
simplest deployent =
Copy unpacked directory hierarchy into a subdirectory in directory $CATALINA_BASE/webapps/



conf/tomcat-users.xml


Access to the manager application is protected by default: you need to define a user with the
role "manager" in /etc/tomcat6/tomcat-users.xml before you can access it.





$CATALINA_BASE  (for multiple instances/aka users? this can be a variable, otherwise =
$CATALINA_HOME (/usr/share/tomcat6


pwd $TOMCAT_HOME

  $TOMCAT_HOME/conf/sever.xml


$CATALINA_HOME/bin/startup.sh
(if $CATALINA_HOME is improperly configured you might look for /home/uesrname/apache-tomcat-6)


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$CATALINA_HOME/bin/jsvc/native/tomcat.sh can be an example auto-starting Tomcat at boot time
(/etc/init.d)



cd $CATALINA_HOME
    ./bin/jsvc -cp ./bin/bootstrap.jar \
        -outfile ./logs/catalina.out -errfile ./logs/catalina.err \
        org.apache.catalina.startup.Bootstrap



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Tomcat Manager App can deploy a new application Remotely, Local Path,
list currently deployed apps, and redploy or reload an app / .war


 $CATALINA_BASE/conf/[enginename]/[hostname]

cp  /var/lib/tomcat6/conf/Catalina/localhost/manager.xml

<Context path="/manager" privileged="true"
         docBase="/usr/local/tomcat6/server/manager">
         <Valve className="org.apache.catalina.valves.RemoteAddrValve"
                allow="127\.0\.0\.1"/>
</Context>



manager-gui - Allows access to the html interface
manager-script - Allows access to the plain text interface
manager-jmx - Allows access to the JMX proxy interface
manager-status - Allows access to the read-only status pages


http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html

  • « Ldap apacheds custom schema ldif
  • App properties read value requires java util »

Published

Aug 28, 2012

Category

java

~555 words

Tags

  • install 58
  • java 252
  • linux 249
  • manual 3
  • servlets 1
  • tomcat 8
  • windows 72