Auto-Start Tomcat on Ubuntu Boot Using systemd

Learn how to configure Apache Tomcat to start automatically on system boot in Ubuntu using systemd service units. A complete step-by-step guide.

Apache Tomcat is not configured with autostart by default in Ubuntu. So, custom init script is required to configure Tomcat for autostart on startup.

Create the init script in /etc/init.d/tomcat8 with the contents as per below.

Init script contents:

#!/bin/bash

### BEGIN INIT INFO
# Provides:        tomcat8
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

start() {
 sh {tomcat_root}/bin/startup.sh
}

stop() {
 sh {tomcat_root}/bin/shutdown.sh
}

case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac

Note: Please change {tomcat_root} with your Tomcat installation folder path.

Change its permissions and add the correct symlinks automatically:

chmod 755 /etc/init.d/tomcat8
update-rc.d tomcat8 defaults

And from now on it will be automatically started and shut down upon entering the appropriate run levels.

It could be also controlled with just use following commands like Apache

service tomcat8 <stop|start|restart>

Using above process any server script can be created and configured to start on startup.

Fix: phpMyAdmin Gives 404 Error in Localhost

Troubleshooting guide to fix the 404 error when accessing phpMyAdmin on localhost. Learn common causes and step-by-step solutions for Apache and Nginx servers.

To run phpmyadmin without getting 404 error, configure apache.conf for phpmyadmin.

gksu gedit /etc/apache2/apache2.conf

Then add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

And restart apache

/etc/init.d/apache2 restart

Please read this section in Ubuntu wiki describes the 404 error problem for phpmyadmin.

Fix cPanel SoftException: GID of Script is Smaller Than min_gid

Learn how to resolve the cPanel SoftException error ‘GID of script is smaller than min_gid’. Step-by-step guide to fix permission and ownership issues.

After upgrading EasyApache in WHM, sometimes it gives 500 (Internal Server Error) error in the browser.  If you check the error_log file, you find:

SoftException in Application.cpp:363: GID of script "/home/current_user/public_html/index.php" is smaller than min_gid

OR

SoftException in Application.cpp:363: UID of script "/home/current_user/public_html/index.php" is smaller than min_uid

If you check the permission of user/group for this file, it gives you root. So, apache can’t read these files uploaded by the root user. One solution is to change the permission of user/group to your current user.

chown current_user:current_user /home/current_user/public_html/ -R

This will solve the permission related issue on your site.

References :
http://www.flynsarmy.com/2011/10/cpanel-softexception-uid-is-smaller-than-min_uid/
http://forums.eukhost.com/f15/how-solve-error-softexception-application-cpp-303-a-6205/