Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Install JDK 7 -- see my JDK 7 installation post.
- download package by going to http://tomcat.apache.org/download-70.cgi or using command below:
- wget http://www.trieuvan.com/apache/tomcat/tomcat-7/v7.0.30/bin/apache-tomcat-7.0.30.tar.gz
- unpack the package:
- tar xvzf apache-tomcat-7.0.30.tar.gz
- move and rename directory:
- sudo mv apache-tomcat-7.0.30/ /usr/share/tomcat7
- define the environment variables JAVA_HOME and JRE_HOME. edit /etc/environment file:
- sudo nano /etc/environment
- record the routes where we have installed Java:
- add the following entry:
- JAVA_HOME="/usr/lib/jvm/jdk1.7.0"
- JRE_HOME="/usr/lib/jvm/jdk1.7.0/jre"
- append java path to the PATH environment variable:
- PATH="...(other path):$JAVA_HOME:$JRE_HOME"
- add routes to catalina.sh:
- sudo nano /usr/share/tomcat7/bin/catalina.sh
- insert the JAVA_HOME and JRE_HOME after the first line. it looks like below:
- #!/bin/sh
- JAVA_HOME="/usr/lib/jvm/jdk1.7.0"
- JRE_HOME="/usr/lib/jvm/jdk1.7.0/jre"
- # Licensed to the Apache Software Foundation (ASF)...
- #...
- #...
- configure Tomcat users, this is done in the file "tomcat-users.xml"directory tomcat7/conf. Command to edit the file:
- sudo nano /usr/share/tomcat7/conf/tomcat-users.xml
- administrator should own role "manager-gui"to operate on the web administration tomcat7. The file would be as follows:
- <?xml version='1.0' encoding='utf-8'?>
- <tomcat-users>
- <role rolename="manager-gui"/>
- <role rolename="manager-script"/>
- <role rolename="manager"/>
- <role rolename="admin-gui"/>
- <role rolename="admin-script"/>
- <role rolename="admin"/>
- <user username="tomcat" password="secret" roles="manager-gui,admin-gui,manager,admin,manager-script,admin-script"/>
- </tomcat-users>
- start server command:
- sudo /usr/share/tomcat7/bin/startup.sh
- to check if tomcat7 is running properly:
- http://127.0.0.1:8080/
- to access tomcat administration manager:
- http://127.0.0.1:8080/manager/html
- to run java samples:
- http://127.0.0.1:8080/examples/
- stop server command:
- sudo /usr/share/tomcat7/bin/shutdown.sh
- ----------------------------------------------------------------------------------------
- Automatic Starting
- To make tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.
- sudo gedit /etc/init.d/tomcat7
- Now paste in the following:
- # Tomcat auto-start
- #
- # description: Auto-starts tomcat
- # processname: tomcat
- # pidfile: /var/run/tomcat.pid
- case $1 in
- start)
- sh /usr/share/tomcat7/bin/startup.sh
- ;;
- stop)
- sh /usr/share/tomcat7/bin/shutdown.sh
- ;;
- restart)
- sh /usr/share/tomcat7/bin/shutdown.sh
- sh /usr/share/tomcat7/bin/startup.sh
- ;;
- esac
- exit 0
- You’ll need to make the script executable by running the chmod command:
- sudo chmod 755 /etc/init.d/tomcat7
- The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.
- sudo ln -s /etc/init.d/tomcat7 /etc/rc1.d/K99tomcat
- sudo ln -s /etc/init.d/tomcat7 /etc/rc2.d/S99tomcat
- Tomcat should now be fully installed and operational.
- sudo /etc/init.d/tomcat7 restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement