To do this, issue the command sudo nano /etc/systemd/system/rvice. With that information in hand, you can create the necessary systemd service. The JAVA_HOME variable, however, must end in jre, so the path will be: /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre In my case, that path is: /usr/lib/jvm/java-1.8.0-openjdk-amd64
You should be presented with the full path to the java installation. To find this location, issue the command: sudo update-java-alternatives -l To do this you need to first find out where java is installed. We need to make sure that systemd is aware of tomcat, so it can be run as a service. Next change the ownership of a few subdirectories, with the command: sudo chown -R tomcat webapps/ work/ temp/ logs/ Create the necessary systemd service file sudo chmod -R g+r confsudo chmod g+x conf This can be done with the following commands: cd /opt/tomcat Now we need to change the permissions for our newly created directory. sudo tar xzvf apache-tomcat-8*tar.gz -C /opt/tomcat -strip-components=1 Now we'll create the target directory and unpack tomcat with the following two commands: sudo mkdir /opt/tomcat Note: In the above command, that is an O not a zero.
To do that, you must first download the necessary file with the command: curl -O Although you can install Tomcat from a repository, we're going to download the file and install it manually.
Installing TomcatĪnd now we must install Tomcat on our server. The above command will ensure that no one can login with the user tomcat and sets the default home to /opt/tomcat (where we will be installing Tomcat). This is accomplished with the command: sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat Next we add the user and add it to the tomcat group we just created. The first thing to do is create the group with the command: sudo groupadd tomcat
Now we must create both a group and user for Tomcat.