Monday, December 10, 2012

Installing Sun JDK, MySql and Apache Tomcat on Ubuntu Linux


Sun Java 6 Installation

To install Sun JDK 6 on ubuntu:

1. Open Terminal
To open Terminal click the Dash home from unity launcher. And type terminal in the search field.And click Terminal.

2. Type the below code in terminal and hit enter.
sudo add-apt-repository ppa:ferramroberto/java
Type your ubuntu password if needed and press enter.

3. Then press enter to continue or ctrl-c to cancel adding the ppa.
  
4. Type below command and hit enter
sudo apt-get update

5. Then type below command and press enter
sudo apt-get install sun-java6-jdk sun-java6-plugin

6. Type y and hit enter to confirm the installation.

7. Select
OK
and press enter enter

8 . To accecpt the DLJ licence select yes and press enter  

9. After the successful installation,to check the installed version type
java -version

MySQL 5.0 Installation 

MySQL is a fast, multi-threaded, multi-user, and robust SQL database server. It is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.

Installation 
To install MySQL 5.0, Run the following command from a terminal prompt:
sudo apt-get install mysql-server

During the installation process you will be prompted to enter a password for the MySQL root user.
Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:
sudo netstat -tap | grep mysql

When you run this command, you should see the following line or something similar:

tcp        0      0 localhost.localdomain:mysql           *:* LISTEN -

If the server is not running correctly, you can type the following command to start it:
sudo /etc/init.d/mysql restart

Configuration

You can edit the /etc/mysql/my.cnf file to configure the basic settings -- log file, port number, etc.
For example, to configure MySQL to listen for connections from network hosts, change the bind_address directive to the server's IP address:

bind-address            = 192.168.0.5

[Note]     

Replace 192.168.0.5 with the appropriate address.

After making a change to /etc/mysql/my.cnf the mysql daemon will need to be restarted:

sudo /etc/init.d/mysql restart


Resources

See the MySQL Home Page for more information.

The MySQL Handbook is also available in the mysql-doc-5.0 package. To install the package enter the following in a terminal:

sudo apt-get install mysql-doc-5.0

The documentation is in HTML format, to view them enter
file:///usr/share/doc/mysql-doc-5.0/refman-5.0-en.html-chapter/index.html 
in your browser's address bar.

Run MySql Server:
Launch terminal and execute following command

mysql -h <ipaddress> -u <username> -p

for example

mysql -h localhost -u srinu -p

This will prompt for the password, once successfully entered will show you the following mysql prompt

mysql>   

Install Apache Tomcat 7 on Ubuntu
Apache has officially launched version 7.0 of the servlet container for Java applications, Tomcat. Major changes in this version, you can highlight support for Servlet 3.0 and JavaServer Pages 2.2.

Installation:

1. Install JDK
2. download the package "apache-tomcat-7.0.6.tar.gz" from http://tomcat.apache.org/download-70.cgi [tar.gz]

Now unpack it with the following command:
tar xvzf apache-tomcat-7.0.8.tar.gz

Then we let in a more appropriate directory, in our case in /usr/share/tomcat7, but can be in any directory.

We do this with the command:
sudo mv apache-tomcat-7.0.8/ /usr/share/tomcat7

Now we define the environment variables
JAVA_HOME and JRE_HOME

This file is in the "environment" in /etc. 

Command to edit the file:
sudo gedit /etc/environment

Here we record the routes where we have installed Java in my case this is as follows:

JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"

PATH="...(other path):$JAVA_HOME:$JRE_HOME"

IMPORTANT: Verify the routes where they have installed Java.

I have had some problems in defining these environment variables,
as sometimes tomcat does not recognize,
but a surefire way of recognizing that tomcat is to define the file paths inside "catalina.sh"located intomcat7/bin.

To modify this file use the command:
sudo gedit /usr/share/tomcat7/bin/catalina.sh

Now just insert the JAVA_HOME and JRE_HOME after the first line,
so the file is as follows:

#!/bin/sh
JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
# Licensed to the Apache Software Foundation (ASF)...
#...
#...
....

Now let's configure Tomcat users,
this is done in the file "tomcat-users.xml"directory tomcat7/conf.

Unlike previous versions where the administrator should own role "manager" now it should be "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="usuario" password="contrasena" roles="manager-gui,admin-gui,manager,admin,manager-script,admin-script"/>
</tomcat-users>



Now you should be all ready to try tomcat7.

First we must lift the server with the following command:
sudo /usr/share/tomcat7/bin/startup.sh

With this we get the following output on console:

Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using JRE_HOME: /usr/local/jdk1.6.0_20/jre
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar

Verify that the JRE_HOME is where we define.

Now open your web browser and type the following url:

http://127.0.0.1:8080/

If we enter the administration Tomcat Manager we click on the menu or directly at URL:

http://127.0.0.1:8080/manager/html

Here we ask the user data from previous record in mind tomcat-users.xml.

I recommend testing the sample to make sure everything works ok, they are in the section "Miscellaneous" from the side menu or at the URL:
http://127.0.0.1:8080/examples/

Commands

Start server:
sudo /usr/share/tomcat7/bin/startup.sh

Stop server:
sudo /usr/share/tomcat7/bin/shutdown.sh


Tomcat should now be fully installed and operational. Enjoy!

1 comment:

  1. Here I came to know how to Install Sun JDK, MySql and Apache Tomcat on Ubuntu Linux with clear steps.I try this in my Apache tomcat training in hyderabad thank you.

    ReplyDelete