Hands-on: Setting Up Tomcat and Apache in CentOS (Self Implemented)

Step-1. Install CentOS 6 or letter (I have used CentOS 6)
Step-2. yum -y update (Solve: Another app is currently holding the yum lock; waiting for it to exit…)
Solution if you fail to stop the process :
#rm -f /var/run/yum.pid 2600
then update your yum
# yum -y update

yum clean all
rpm --rebuilddb

Make sure that yum-updatesd is started :
#/etc/init.d/yum-updatesd status
# /etc/init.d/yum-updatesd start
NB: This can be dangerous especially if you kill the wrong PID by mistake.

Code:
 # ps -ef | grep yum
root      3185  1207  0 14:47 pts/1    00:00:00 grep yum
root      3804     1  0 Jan11 ?        00:00:43 /usr/bin/python -tt /usr/sbin/yum-updatesd
# kill -9 3804
# ps -ef | grep yum
root      3197  1207  0 14:48 pts/1    00:00:00 grep yum
# yum update

Step-3. Step 1: Install JDK 1.8
You can download the latest JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html this will download the jdk-8u20-linux-x64.tar.gz to the folder/ directory /home/IICT/Downloads/jdk-8u20-linux-x64.tar.gz . Now su root and copy the file to the /usr/java/

su root
mkdir /usr/java
cp /home/IICT/Downloads/jdk-8u20-linux-x64.tar.gz /usr/java/
cd /usr/java/
tar -xzf jdk-8u20-linux-x64.tar.gz
JAVA_HOME=/usr/java/jdk1.8.0_20
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
echo $JAVA_HOME
Output: /usr/java/jdk1.8.0_20
Step-4. Setup tomcat 7
Download tomcat 7 or 8 in .tar.gz format (do not install using yum install tomcat from internet in .rpm format) from http://tomcat.apache.org/download-70.cgi . this will download the .tar.gz file in /home/IICT/Downloads directiry. copy them to /usr/share/

cp /home/IICT/Downloads/apache-tomcat-7.0.55.tar.gz /usr/share/
cd /usr/share/
tar -xzf apache-tomcat-7.0.55.tar.gz

cd /etc/init.d/
nano tomcat (script is)
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.8.0_20
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.55
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
(in cd /etc/init.d/)
chmod 755 tomcat
chkconfig –add tomcat
chkconfig –level 234 tomcat on
chkconfig –list tomcat
Output: tomcat 0:off 1:off 2:on 3:on 4:on 5:off 6:off
service tomcat start
service tomcat stop
service tomcat start
service tomcat restart
Output: Tomcat started.
[tomcat installation is ready… let set go]

Step-5: Install PHP:
yum install php
Total download size: 3.8 M
Installed size: 13 M
Is this ok [y/N]: y
Output: Complete!
Default Deployment folder/ directory for tomcat is  /usr/share/apache-tomcat-7.0.55/webapps/ROOT/  (.war deploy here)
and default Deployment folder of Apache is /var/www/html/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s