Saturday, February 23, 2013

Installing windows related features in Ubuntu

One of the first things you should do with a fresh install is install ubuntu-restricted-extras package.

This package installs various video/audio codes windows fonts unrar unzip flash java etc.


sudo apt-get install ubuntu-restricted-extras

Friday, February 22, 2013

Installing Tomcat 6 on Ubuntu

Installing Tomcat 6

Installing tomcat 6 on Ubuntu is a step by step process, where you need to follow the following steps carefully.

$ sudo apt-get install tomcat6

Editing the edit tomcat-users.xml:

Declaring users and roles


sudo chmod 777 tomcat-users.xml

$ vi tomcat-users.xml


Usernames, passwords and roles (groups) can be defined centrally in a Servlet container. In Tomcat 6.0 this is done in the/etc/tomcat6/tomcat-users.xml file:
<user username="tomcat" password="s3cret" roles="standard, manager-gui"/>


And don't forget to revert these changes.

sudo chmod 640 tomcat-users.xml

Starting and stopping tomcat 6:

$ sudo service tomcat6 stop

sudo service tomcat6 start

Now you can check your server running on your system:

Open any browser and use localhost:8080 or IPaddressofYourSystem:8080

Ex: 127.0.0.1:8080 or 192.168.1.4:8080

Important tips for running tomcat successfully and using other useful utilities:


Changing default ports:

By default Tomcat 6.0 runs a HTTP connector on port 8080 and an AJP connector on port 8009. You might want to change those default ports to avoid conflict with another server on the system. This is done by changing the following lines in /etc/tomcat6/server.xml:
<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
...
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Changing JVM used

By default Tomcat will run preferably with OpenJDK-6, then try Sun's JVM, then try some other JVMs. If you have various JVMs installed, you can set which should be used by setting JAVA_HOME in /etc/default/tomcat6:
JAVA_HOME=/usr/lib/jvm/java-6-sun

Using Tomcat standard webapps


Tomcat is shipped with webapps that you can install for documentation, administration or demo purposes.

Tomcat documentation

The tomcat6-docs package contains Tomcat 6.0 documentation, packaged as a webapp that you can access by default at http://yourserver:8080/docs. You can install it by entering the following command in the terminal prompt:
sudo apt-get install tomcat6-docs

Tomcat administration webapps

The tomcat6-admin package contains two webapps that can be used to administer the Tomcat server using a web interface. You can install them by entering the following command in the terminal prompt:
sudo apt-get install tomcat6-admin
The first one is the manager webapp, which you can access by default at http://yourserver:8080/manager/html. It is primarily used to get server status and restart webapps.
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.
The second one is the host-manager webapp, which you can access by default at http://yourserver:8080/host-manager/html. It can be used to create virtual hosts dynamically.
Access to the host-manager application is also protected by default: you need to define a user with the role "admin" in/etc/tomcat6/tomcat-users.xml before you can access it.
For security reasons, the tomcat6 user cannot write to the /etc/tomcat6 directory by default. Some features in these admin webapps (application deployment, virtual host creation) need write access to that directory. If you want to use these features execute the following, to give users in the tomcat6 group the necessary rights:
sudo chgrp -R tomcat6 /etc/tomcat6
sudo chmod -R g+w /etc/tomcat6 

Tomcat examples webapps

The tomcat6-examples package contains two webapps that can be used to test or demonstrate Servlets and JSP features, which you can access them by default at http://yourserver:8080/examples. You can install them by entering the following command in the terminal prompt:
sudo apt-get install tomcat6-examples

Using private instances

Tomcat is heavily used in development and testing scenarios where using a single system-wide instance doesn't meet the requirements of multiple users on a single system. The Tomcat 6.0 packages in Ubuntu come with tools to help deploy your own user-oriented instances, allowing every user on a system to run (without root rights) separate private instances while still using the system-installed libraries.
It is possible to run the system-wide instance and the private instances in parallel, as long as they do not use the same TCP ports.

Installing private instance support

You can install everything necessary to run private instances by entering the following command in the terminal prompt:
sudo apt-get install tomcat6-user

Creating a private instance

You can create a private instance directory by entering the following command in the terminal prompt:
tomcat6-instance-create my-instance
This will create a new my-instance directory with all the necessary subdirectories and scripts. You can for example install your common libraries in the lib/ subdirectory and deploy your webapps in the webapps/ subdirectory. No webapps are deployed by default.

Configuring your private instance

You will find the classic Tomcat configuration files for your private instance in the conf/ subdirectory. You should for example certainly edit the conf/server.xml file to change the default ports used by your private Tomcat instance to avoid conflict with other instances that might be running.

Opening firewall port:
$ sudo ufw enable 8080/tcp


Sources:
Ubuntu Documentation