Download and Install JAVA
Download j2sdk-1.4.2 from Sun Download center Sun Developer Network (SDN) Downloads Here I have used j2sdk-1_4_2_18-linux-i586-rpm.bin which will install j2sdk using RPMS and set the Path of JAVA_HOME automatically
Now Check if Java is installed on the server using command java -version
Download Tomcat
Create Symlink for the Tomcat Folder
Install Tomcat
Start Tomcat
Use Following script to start Tomcat Service on the Server
Running Tomcat as non root user
Due to security reasons always run tomcat as non-root user i.e. tomcat. Following are the steps to run tomcat as non-root user
Now Tomcat can be stopped and started under user tomcat using following commands:
Test Tomcat installation
open a browser and browse website http://xx.xx.xx.xx:8080 where xx.xx.xx.xx will be your Server IP and If you get following output than Tomcat has been installed properly on the Server.
Script to start, stop and restart Tomcat
The above installation step will not create tomcat service so that user can restart tomcat using command service tomcat restart. Create a new file in /etc/init.d as tomcat and copy following contenents into it.
Save and exit from the file. Now assign executable permission to this file
Add and Enable tomcat for all the Run-levels
Now you can restart tomcat service using following commands (you can check the screenshot too)
#service tomcat restart <<< To restart tomcat
#service tomcat stop <<< To stop Tomcat
#service tomcat start <<< To start Tomcat
#service tomcat Status <<< to check the status of Tomcat
Add username/Password for tomcat manager:
How to add a new user name to tomcat manager:
just add line number 3 and 6 to /install/apache-tomcat-5.5.29/conf/tomcat-users.xml
1) <?xml version='1.0' encoding='utf-8'?>
2) <tomcat-users>
3) <role rolename="manager"/>
4) <role rolename="tomcat"/>
5) <role rolename="role1"/>
6) <user username="manager" password="tomcat" roles="manager,tomcat"/>
7) <user username="tomcat" password="tomcat" roles="tomcat"/>
8) <user username="both" password="tomcat" roles="tomcat,role1"/>
9) <user username="role1" password="tomcat" roles="role1"/>
10) </tomcat-users>
Restart tomcat server.
By using service tomcat restart.
Download j2sdk-1.4.2 from Sun Download center Sun Developer Network (SDN) Downloads Here I have used j2sdk-1_4_2_18-linux-i586-rpm.bin which will install j2sdk using RPMS and set the Path of JAVA_HOME automatically
Quote:
#chmod +x j2sdk-1_4_2_09-linux-i586.bin #./j2sdk-1_4_2_09-linux-i586.bin |
Quote:
[root@vps907 ~]# java -version java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06) Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing) |
Quote:
#cd /usr/local/ #wget Blue Dog Fan Blogs #tar -zxvf apache-tomcat-6.0.18.tar.gz |
Quote:
#ln -s /usr/local/apache-tomcat-6.0.18 /usr/local/apache/tomcat |
Quote:
#cd apache-tomcat-6.0.18 #cd bin #tar xvfz jsvc.tar.gz #cd jsvc-src #chmod +x configure #./configure #make #cp jsvc .. #cd .. |
Use Following script to start Tomcat Service on the Server
Quote:
#/usr/local/apache/tomcat/bin/startup.sh |
Due to security reasons always run tomcat as non-root user i.e. tomcat. Following are the steps to run tomcat as non-root user
Quote:
#chown tomcat.tomcat /usr/local/apache-tomcat-6.0.18 -R |
Quote:
#su -l tomcat -c /usr/local/apache/tomcat/bin/startup.sh #su -l tomcat -c /usr/local/apache/tomcat/bin/shutdown.sh |
open a browser and browse website http://xx.xx.xx.xx:8080 where xx.xx.xx.xx will be your Server IP and If you get following output than Tomcat has been installed properly on the Server.
Script to start, stop and restart Tomcat
The above installation step will not create tomcat service so that user can restart tomcat using command service tomcat restart. Create a new file in /etc/init.d as tomcat and copy following contenents into it.
Quote:
#vi /etc/init.d/tomcat #!/bin/bash # # Startup script for Tomcat # # chkconfig: 345 84 16 # description: Tomcat jakarta JSP server #Necessary environment variables export CATALINA_HOME="/usr/local/tomcat" if [ ! -f $CATALINA_HOME/bin/catalina.sh ] then echo "Tomcat not available..." exit fi start() { echo -n -e '\E[0;0m'"\033[1;32mStarting Tomcat: \033[0m \n" su -l tomcat -c $CATALINA_HOME/bin/startup.sh echo touch /var/lock/subsys/tomcatd sleep 3 } stop() { echo -n -e '\E[0;0m'"\033[1;31mShutting down Tomcat: \033[m \n" su -l tomcat -c $CATALINA_HOME/bin/shutdown.sh rm -f /var/lock/subsys/tomcatd echo } status() { ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' > /tmp/tomcat_process_count.txt read line < /tmp/tomcat_process_count.txt if [ $line -gt 0 ]; then echo -n "tomcatd ( pid " ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' echo -n ") is running..." echo else echo "Tomcat is stopped" fi } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 3 start ;; status) status ;; *) echo "Usage: tomcatd {start|stop|restart|status}" exit 1 esac |
Quote:
#chown 755 /etc/init.d/tomcat |
Quote:
#chkconfig --add tomcat #chkconfig tomcat on |
#service tomcat restart <<< To restart tomcat
#service tomcat stop <<< To stop Tomcat
#service tomcat start <<< To start Tomcat
#service tomcat Status <<< to check the status of Tomcat
Add username/Password for tomcat manager:
How to add a new user name to tomcat manager:
just add line number 3 and 6 to /install/apache-tomcat-5.5.29/conf/tomcat-users.xml
1) <?xml version='1.0' encoding='utf-8'?>
2) <tomcat-users>
3) <role rolename="manager"/>
4) <role rolename="tomcat"/>
5) <role rolename="role1"/>
6) <user username="manager" password="tomcat" roles="manager,tomcat"/>
7) <user username="tomcat" password="tomcat" roles="tomcat"/>
8) <user username="both" password="tomcat" roles="tomcat,role1"/>
9) <user username="role1" password="tomcat" roles="role1"/>
10) </tomcat-users>
Restart tomcat server.
By using service tomcat restart.
0 Comment:
Post a Comment