Thursday, October 20, 2016

Install Oracle JDK 8 and Apache Tomcat 8

Installing the Oracle JDK
=========================

1. sudo add-apt-repository ppa:webupd8team/java
2. sudo apt-get update
3. sudo apt-get install oracle-java8-installer
4. sudo update-alternatives --config java
5. sudo vi /etc/environment
 JAVA_HOME="/usr/lib/jvm/java-8-oracle"
6. source /etc/environment


Installing Apache Tomcat 8
==========================
1. sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
2. dpkg -L tomcat8
3. sudo vi /etc/tomcat8/server.xml

change port 8080 to 8081 since jenkins is using 8080

4. sudo /etc/init.d/tomcat8 restart
5. Check: http://localhost:8081
6. sudo vi /opt/tomcat/conf/tomcat-users.xml
7. sudo /etc/init.d/tomcat8 restart

Re-installing Tomcat 8
======================
1. Getting errors

 Errors were encountered while processing:
 tomcat8
 E: Sub-process /usr/bin/dpkg returned an error code (1)

2. sudo dpkg -P libtomcat8-java tomcat8-common tomcat8-docs tomcat8 tomcat8-examples tomcat8-admin

3. sudo apt-get purge libtomcat8-java tomcat8 tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

4. sudo reboot

Install Oracle JDK 8 and Apache Tomcat 8

Installing the Oracle JDK
=========================

1. sudo add-apt-repository ppa:webupd8team/java
2. sudo apt-get update
3. sudo apt-get install oracle-java8-installer
4. sudo update-alternatives --config java
5. sudo vi /etc/environment
   JAVA_HOME="/usr/lib/jvm/java-8-oracle"
6. source /etc/environment


Installing Apache Tomcat 8
==========================
1. sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
2. dpkg -L tomcat8
3. sudo vi /etc/tomcat8/server.xml
change port 8080 to 8081 since jenkins is using 8080

4. sudo /etc/init.d/tomcat8 restart
5. Check: http://localhost:8081
6. sudo vi /opt/tomcat/conf/tomcat-users.xml 
7. sudo /etc/init.d/tomcat8 restart



Re-installing Tomcat 8
======================
1. Getting errors

   Errors were encountered while processing:
   tomcat8
   E: Sub-process /usr/bin/dpkg returned an error code (1)

2. sudo dpkg -P libtomcat8-java tomcat8-common tomcat8-docs tomcat8 tomcat8-examples tomcat8-admin

3. sudo apt-get purge libtomcat8-java tomcat8 tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

4. sudo reboot








Install Oracle JDK 8 and Apache Tomcat 8

Installing the Oracle JDK
=========================

1. sudo add-apt-repository ppa:webupd8team/java
2. sudo apt-get update
3. sudo apt-get install oracle-java8-installer
4. sudo update-alternatives --config java
5. sudo vi /etc/environment
   JAVA_HOME="/usr/lib/jvm/java-8-oracle"
6. source /etc/environment


Installing Apache Tomcat 8
==========================
1. sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
2. dpkg -L tomcat8
3. sudo vi /etc/tomcat8/server.xml
change port 8080 to 8081 since jenkins is using 8080

4. sudo /etc/init.d/tomcat8 restart
5. Check: http://localhost:8081
6. sudo vi /opt/tomcat/conf/tomcat-users.xml 
7. sudo /etc/init.d/tomcat8 restart



Re-installing Tomcat 8
======================
1. Getting errors

   Errors were encountered while processing:
   tomcat8
   E: Sub-process /usr/bin/dpkg returned an error code (1)

2. sudo dpkg -P libtomcat8-java tomcat8-common tomcat8-docs tomcat8 tomcat8-examples tomcat8-admin

3. sudo apt-get purge libtomcat8-java tomcat8 tomcat8-admin tomcat8-common tomcat8-docs tomcat8-examples tomcat8-user

4. sudo reboot









Installing monit in Ubuntu (IP: 10.20.30.40)


1. Repair missing LSB tags on tomcat and vncserver and other daemon as well

   $ sudo vi tomcat 
   $ sudo vi vncserver 
  
  add this after shebang
  
  ### BEGIN INIT INFO
  # Provides:          skeleton
  # Required-Start:    $remote_fs $syslog
  # Required-Stop:     $remote_fs $syslog
  # Default-Start:     2 3 4 5
  # Default-Stop:      0 1 6
  # Short-Description: Example initscript
  # Description:       This file should be used to construct script
  #                    placed in /etc/init.d.
  ### END INIT INFO
  
  
2. Install monit
   $ sudo apt-get install monit
   
   
3. Edit /etc/monit/monitrc
$ sudo vi /etc/monit/monitrc

3.1. Uncomment this section:

set httpd port 2812 and
         use address 10.20.30.40 # only accept connection from localhost
         allow 0.0.0.0/0.0.0.0   # allow localhost to connect to the server and
         allow admin:monit      # require user 'admin' with password 'monit'
         allow @users readonly  # allow users of group 'users' to connect readonly 

3.2. Append at the end of the config

# monitor sshd
check process sshd with pidfile /var/run/sshd.pid
#
# monitor jenkins
check process jenkins with pidfile /var/run/jenkins/jenkins.pid
#
# monitor apache2
check process apache2 with pidfile /var/run/apache2/apache2.pid


4. Install upstart
$ sudo apt-get install upstart-sysv

5. Reload monit
$ sudo reload monit

OR

$ sudo service monit restart

6. Open browser and check
http://10.20.30.40:2812/