1. vi/etc/init.d/tomcat7,
Add below segment to the file, replace the ones marked in red by your tomcat installed path.
# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
case $1 in
start)
sh /usr/share/tomcat7/bin/startup.sh
;;
stop)
sh /usr/share/tomcat7/bin/shutdown.sh
;;
restart)
sh /usr/share/tomcat7/bin/shutdown.sh
sh /usr/share/tomcat7/bin/startup.sh
;;
esac
exit 0
2. Add the autostart service to your server
sudo chmod 755 /etc/init.d/tomcat7
sudo update -rc.d tomca7 defaults
3. Restart your server