Sunday 7 August 2011

How to setup Java and Tomcat7 on Linux

Hi there, as part of my new linux server installation, I planed to document everything I install and setup, so that anyone who need help installing thoese packages [including me in the future] can refer to this information. On this series  I will explain how to setup Java & tomcat7 (current version as of writing).

First, Download jdk, you can install jre itself, but in my case need jdk as I compile my sourcecodes on the same server.
#wget <URL_OF_YOUR_VERSION_OF_JAVA.bin>
To install to a system-wide location create a directoy under /usr
#mkdir /usr/java
#mv <URL_OF_YOUR_VERSION_OF_JAVA.bin> /usr/java/
Change the file mode to executable and run.
#cd /usr/java
#chmod a+x <URL_OF_YOUR_VERSION_OF_JAVA.bin>
#./<URL_OF_YOUR_VERSION_OF_JAVA.bin>
 This will install java on the server. A new directiory will be created under the current directory with java tools. you can creat a softlink to the directory as jdk.
#ln -s   jdk1.6.0_25 jdk
I will tell you where to set the Environment veriables shortly after installing the tomcat.

Download Tomcat, you can choose the tar.gz archive. move it to the system-wide location, such as /usr/local and extract the contents.

#wget <URL_OF_YOUR_VERSION_OF_TOMCAT.tar.gz>
#mv <URL_OF_YOUR_VERSION_OF_TOMCAT.tar.gz> /usr/local/
#cd /usr/local
#tar -zxvf   <URL_OF_YOUR_VERSION_OF_TOMCAT.tar.gz>
This will create a tomcat directory under the /usr/local, you can make a symlink to the directory with a nick name,
#ln -s apache-tomcat-7.0.19 tomcat7
Now we need to tell the system where is the java bin directory and the tomcat bin directory.

To set the PATH veriable permanently, with these bin directories for a perticular user you need to add the path entries to that users .bash_profile file. If you want to set these variables for all users you may have to add the path entries in the /etc/profile
Either case, you will have to add the following script to the end of the file whichever you choose (Single User/ All Users).
JAVA_HOME=/usr/java/jdk
CATALINA_HOME=/usr/local/tomcat7
PATH=$PATH:JAVA_HOME/bin:CATALINA_HOME/bin
export JAVA_HOME
export CATALINA_HOME
export PATH

Now logout and login to see whether you get java commands.
#java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)

To test tomcat, run it using the startup.sh command and browse the page localhost:8080/ ot <ip>:8080/
you should see the default page of tomcat.

Thanks for reading...

Thursday 28 July 2011

Linux Copy Command for Remote Server to another Server

Hi, today I was moving my server to cloud. As part of that process, I need to copy all my files to the linux server in a cloud environment. How am i going to copy the files securly from a distance server to another distance server. Its so simple with linux

scp user@sourceServer:/file/folder/location user@destinationServer:/destination/folder
You can use the IP/domain Name of the destination/source server.
For example;
scp banu@192.168.100.5:/home/banu/myfile banu@192.168.100.55:/home/banu/
scp -r banu@192.168.100.5:/home/banu/myfolder banu@192.168.100.55:/home/banu/
 In the second Example, the -r signals for recursive copy.

Hope this might help someone.