Thursday, March 27, 2008

Tomcat+Java Installation.

Java Installation


I chose to install Sun's Java 2 Platform, Standard Edition, which can be downloaded from http://java.sun.com/j2se/). I chose the J2SE v1.4.2 SDK Linux self-extracting binary file.

Change to the directory where you downloaded the SDK and make the self-extracting binary executable:

chmod +x j2sdk-1_4_2-linux-i586.bin

Run the self-extracting binary:

./j2sdk-1_4_2-linux-i586.bin

here should now be a directory called j2sdk1.4.2 in the download directory. Move the SDK directory to where you want it to be installed. I chose to install it in /usr/java. Create /usr/java if it doesn't exist. Here is the command I used from inside the download directory:


mv j2sdk1.4.2 /usr/java


Set the JAVA_HOME environment variable, by modifying /etc/profile so it includes the following:

JAVA_HOME="/usr/java/j2sdk1.4.2"
export JAVA_HOME

/etc/profile is run at startup and when a user logs into the system, so you will need to log out and log back in for JAVA_HOME to be defined.


You should have to logout from the server to check whether its workgin fine.

exit
su -

Check to make sure JAVA_HOME is defined correctly using the command below. You should see the path to your Java SDK.

Check to make sure JAVA_HOME is defined correctly using the command below. You should see the path to your Java SDK.


TOMCAT Installation


Download it from

http://tomcat.apache.org/

You will install and configure Tomcat as root; however, you should create a dedicated group and user account for Tomcat to run under as follows:

groupadd tomcat

useradd -g tomcat tomcat

tar xvzf apche-tomcat-5.0.28.tar.gz

mv jakarta-tomcat-5.0.28 /usr/local/

chown -R tomcat.tomcat /usr/local/apache-tomcat-5.0.28


cd /usr/local/apache-tomcat-5.0.28/bin

tar -xvzf jsvc.tar.gz


cd jsvc-src

chmod +x configure

./configure

make

cp jsvc ..

cd ..

./startup.sh

open web browser and type http://localhost:8080/ you should see the Tomcat Administration page


go to webapps/ROOT in the tomcat directory and create page hello.html and write in it

Hello Tomcat

open the URL http://localhost:8080/hello.html you should see your page

* Make JSP page

go to webapps/ROOT in the tomcat directory and create page hello.jsp and write in it the following lines

< %=new String("Hello Ahmed Hashim")% >


< %=new java.util.Date()% >




save and run the following URL http://localhost:8080/hello.jsp you should see my Name

* Monitor Tomcat

you can see the log file in the logs directory

* Stop Tomcat

go to the tomcat bin directory

#./shutdown.sh



You can add users in

cd /usr/local/tomcat/conf
vi tomcat-users.xml


And access it at

http://localhost:8080/manager/html

Username : from tomcat-users.xml
Password : l...

No comments: