Saturday, May 28, 2011

Install and Configure Tomcat6 on Ubuntu Linux

Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies.

The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process.

Part 1
First, install tomcat6:
sudo apt-get install tomcat6 tomcat6-docs tomcat6-examples tomcat6-admin

Then configure a user to be manager and admin by adding the following lines
  <role rolename="admin"/>
  <role rolename="manager"/>
  <user username="YOURUSERNAME" password="YOURPASSWORD" roles="admin,manager"/>
in your /var/lib/tomcat6/conf/tomcat-users.xml. Make sure you put it between the <tomcat-users> and </tomcat-users> tags and don't forget to replace YOURUSERNAME with your actual username.
Now go to a browser and hit:
and you should see the welcome page.

Part 2
To restart tomcat you just need to say:
sudo /etc/init.d/tomcat6 restart
or if you want to start/stop/get status you just replace restart with start/stop/status.
To make this easier go to a terminal and type:
gedit tomcat
then add the following lines of text:

/etc/init.d/tomcat6 $1
then save and close and type:
chmod u+x tomcat
sudo mv tomcat /usr/local/bin
so if you want to stop tomcat you can now say:
sudo tomcat stop
Let's add auto-completion to our new command now. Open a terminal and type:
gedit tomcat
then copy paste the following
    local cur prev opts
    opts="start stop restart status"

    if [[ ${cur} == * ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
complete -F _tomcat tomcat
save and close gedit. Now type:
sudo mv tomcat /etc/bash_completion.d
You need to restart for this to take effect, but if you want to test it right away type:
. /etc/bash_completion.d/tomcat
Then as an example, type:
sudo tomcat re
and hit tab a couple of times. It should complete the word restart for you since it's the only valid option that begins with "re".

Thursday, May 19, 2011

Install Sun Java JDK in Ubuntu 10.10

To install Sun's Java 6 JDK on Ubuntu 10.10, add the Sun Java6 Community PPA and install:
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin
sudo update-java-alternatives -s java-6-sun