Skip to content

Instantly share code, notes, and snippets.

@jbovet
Last active December 21, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbovet/6321618 to your computer and use it in GitHub Desktop.
Save jbovet/6321618 to your computer and use it in GitHub Desktop.
Install tomcat 7 on CentOS 6

Requirement: JDK 1.6 or later

Download tomcat 7 version:

curl http://apache.mirrors.tds.net/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz | tar xvz

move to share directory

```bash mv apache-tomcat-7.0.42 /usr/share/ ```

create script for tomcat

```bash vi /etc/init.d/tomcat ```

and add the follow lines...

```bash #!/bin/bash # description: Tomcat Start Stop Restart # processname: tomcat # chkconfig: 234 20 80 JAVA_HOME=/usr/java/jdk1.7.0_25 export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH export PATH CATALINA_HOME=/usr/share/apache-tomcat-7.0.42

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


<h5>where JAVA_HOME is your path</h5>
```bash
[root@~]#  echo $JAVA_HOME  
/usr/java/jdk1.7.0_25 

Now, added permissions

```bash [root@init.d]# chmod 755 tomcat [root@init.d]# chkconfig --add tomcat [root@init.d]# chkconfig --level 234 tomcat on ```

check with

```bash [root@init.d]# chkconfig --list tomcat tomcat 0:off 1:off 2:on 3:on 4:on 5:off 6:off ```

now run/stop/restart service

```bash [root@init.d]# service tomcat start [root@init.d]# service tomcat stop [root@init.d]# service tomcat restart ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment