{"id":2226,"date":"2018-11-01T07:25:43","date_gmt":"2018-11-01T07:25:43","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=2226"},"modified":"2018-11-02T10:08:26","modified_gmt":"2018-11-02T10:08:26","slug":"install-tomcat-on-ubuntu-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/01\/install-tomcat-on-ubuntu-linux-hint\/","title":{"rendered":"Install Tomcat on Ubuntu | Linux Hint"},"content":{"rendered":"<p>Tomcat also known as Apache Tomcat is a web server just like Apache 2 HTTP server that we mostly use to serve PHP web applications. Apache Tomcat is used to serve Java based web applications. Tomcat has support for many of the Java web technologies such as Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. In this article, I will show you how to install Tomcat web server on Ubuntu 18.04 LTS. So, let\u2019s get started.<\/p>\n<p>Tomcat 8.5.x is available in the universe section of the official package repository of Ubuntu 18.04 LTS. So, it is really easy to install. First, make sure that the universe section of the official Ubuntu 18.04 LTS package repository is enabled.<\/p>\n<p>To do that, run the following command:<\/p>\n<p>$ egrep &#8216;^deb http.*universe.*$&#8217; \/etc\/apt\/sources.list<\/p>\n<p>As you can see, I have the universe section of the official package repository enabled.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"128\" \/><\/p>\n<p>If it\u2019s not enabled in your case, you can easily enable it. If you\u2019re using a desktop environment on your Ubuntu 18.04 LTS machine, then open Software &amp; Updates app and make sure the Community-maintained free and open-source software (universe) repository is checked on the Ubuntu Software tab as marked in the screenshot below. The universe section of the package repository should be enabled.<\/p>\n<p>If you\u2019re using Ubuntu 18.04 LTS server in headless mode, then run the following command to enable the universe section of the package repository:<\/p>\n<p>$ sudo apt-add-repository &#8220;deb http:\/\/us.archive.ubuntu.com\/ubuntu\/ bionic universe&#8221;<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"89\" \/><\/p>\n<p>Now, update the APT package repository cache with the following command:<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1051\" height=\"89\" \/><\/p>\n<p>The APT package repository cache should be updated.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1053\" height=\"211\" \/><\/p>\n<p>Finally, install Tomcat 8.5.x with the following command:<\/p>\n<p>$ sudo apt install tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"88\" \/><\/p>\n<p>Now, press y and then press &lt;Enter&gt; to continue.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"448\" \/><\/p>\n<p>Tomcat 8.5.x should be installed.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"262\" \/><\/p>\n<h2>Starting and Stopping Tomcat Service:<\/h2>\n<p>In this section, I am going to show you how to manage Tomcat service on Ubuntu 18.04 LTS. You can check whether the Tomcat service is running on your Ubuntu 18.04 LTS machine with the following command:<\/p>\n<p>$ sudo systemctl status tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"88\" \/><\/p>\n<p>As you can see, Tomcat service is running.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"410\" \/><\/p>\n<p>If you want to stop Tomcat service, then run the following command:<\/p>\n<p>$ sudo systemctl stop tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"111\" \/><\/p>\n<p>As you can see, Tomcat service is not running anymore.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1138\" height=\"419\" \/><\/p>\n<p>If you want to start the Tomcat service again, then run the following command:<\/p>\n<p>$ sudo systemctl start tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"115\" \/><\/p>\n<p>As you can see, the Tomcat service is running again.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"371\" \/><\/p>\n<h3>Starting Tomcat at System Boot:<\/h3>\n<p>If you want Apache Tomcat server to start when your Ubuntu 18.04 LTS machine boot, then you have to add the Tomcat service to the system startup of your Ubuntu 18.04 LTS machine. To do that, run the following command:<\/p>\n<p>$ sudo systemctl enable tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1136\" height=\"85\" \/><\/p>\n<p>Tomcat service should be added to system startup of your Ubuntu 18.04 LTS machine. The next time you boot, it should automatically start.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"150\" \/><\/p>\n<h3>Removing Tomcat from System Startup:<\/h3>\n<p>If you don\u2019t want to start Apache Tomcat web server when your Ubuntu 18.04 LTS machine boots anymore, all you have to do is remove the Tomcat service from the system startup of your Ubuntu 18.04 LTS machine.<\/p>\n<p>To do that, run the following command:<\/p>\n<p>$ sudo systemctl disable tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"87\" \/><\/p>\n<p>Tomcat service should be removed from the system startup of your Ubuntu 18.04 LTS machine. Apache Tomcat web server won\u2019t start when your Ubuntu machine boots anymore.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"148\" \/><\/p>\n<h3>Accessing Tomcat Web Server:<\/h3>\n<p>By default, Apache Tomcat web server runs on port 8080. If you\u2019re using Ubuntu 18.04 LTS desktop, just open your web browser and visit <a href=\"http:\/\/localhost:8080\">http:\/\/localhost:8080<\/a><\/p>\n<p>As you can see, the welcome screen of Apache Tomcat web server showed up.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"494\" \/><\/p>\n<p>If you\u2019re using Ubuntu 18.04 LTS headless server, then run the following command to get the IP address of your Ubuntu machine which is running the Tomcat web server:<\/p>\n<p>As you can see, the IP address is 192.168.163.134 in my case.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"328\" \/><\/p>\n<p>Now from the web browser of any computer connected to the same network as your Ubuntu server machine, visit <a href=\"http:\/\/IP_ADDR:8080\">http:\/\/IP_ADDR:8080<\/a>, in my case <a href=\"http:\/\/192.168.163.134:8080\">http:\/\/192.168.163.134:8080<\/a><\/p>\n<p>As you can see, I can still access the Tomcat web server running on my Ubuntu machine.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"488\" \/><\/p>\n<h3>Managing Tomcat Web Server Using Web Based Management Interfaces:<\/h3>\n<p>Apache Tomcat has graphical management interfaces which you can use to manage your Tomcat web server from the web browser. In this section, I will show you how to configure it. To get the Tomcat Management interfaces on Ubuntu 18.04 LTS, you have to install 2 additional software packages tomcat8-admin and tomcat8-user.<\/p>\n<p>To do that, run the following command:<\/p>\n<p>$ sudo apt install tomcat8-admin tomcat8-user<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1137\" height=\"94\" \/><\/p>\n<p>tomcat8-admin and tomcat8-user packages should be installed.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"412\" \/><\/p>\n<p>Now you have to configure a username and password that you want to use to log in to the Tomcat Web based management interfaces. To do that you have to edit the configuration file \/etc\/tomcat8\/tomcat-users.xml and add the required roles and users there.<\/p>\n<p>To edit the configuration file \/etc\/tomcat8\/tomcat-users.xml, run the following command:<\/p>\n<p>$ sudo nano \/etc\/tomcat8\/tomcat-users.xml<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"89\" \/><\/p>\n<p>The configuration file should be opened.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"419\" \/><\/p>\n<p>Now navigate to the end of the file and add the following lines just before the &lt;\/tomcat-users&gt; line.<\/p>\n<p>&lt;role rolename=&#8221;admin-gui&#8221;\/&gt;<br \/>\n&lt;role rolename=&#8221;manager-gui&#8221;\/&gt;<br \/>\n&lt;user username=&#8221;YOUR_USERNAME&#8221; password=&#8221;YOUR_PASSWORD&#8221; roles=&#8221;admin-gui,manager-gui&#8221;\/&gt;<\/p>\n<p>Here, change YOUR_USERNAME and YOUR_PASSWORD to the username and password that you want to use to log in to the Tomcat web based management interfaces. I am going to set it to tomcat and tomcat for the demonstration.<\/p>\n<p>Finally, it should look something like this. Now, press &lt;Ctrl&gt; + x and then press y and then press &lt;Enter&gt; to save the changes.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"421\" \/><\/p>\n<p>Now, restart Tomcat service with the following command:<\/p>\n<p>$ sudo systemctl restart tomcat8<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1131\" height=\"113\" \/><\/p>\n<p>Now you can access the Tomcat Web Application Manager interface. Just visit <a href=\"http:\/\/localhost:8080\/manager\/html\">http:\/\/localhost:8080\/manager\/html<\/a> from your web browser and you should be prompted for the username and the password. Type in the username and password you just set and click on OK.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>You should be logged in to the Tomcat Web Application Manager interface. From here, you can manage (start, stop and reload) the running web applications and many more.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>There is also another web app for managing Tomcat web server called Virtual Host Manager which you can access at <a href=\"http:\/\/localhost:8080\/host-manager\/html\">http:\/\/localhost:8080\/host-manager\/html<\/a><\/p>\n<p>As you can see, the Virtual Host Manager interface is displayed in my web browser.<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"644\" \/><\/p>\n<p>So, that\u2019s how you install and use Tomcat web server on Ubuntu 18.04 LTS. Thanks for reading this article.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/install_tomcat_ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tomcat also known as Apache Tomcat is a web server just like Apache 2 HTTP server that we mostly use to serve PHP web applications. Apache Tomcat is used to serve Java based web applications. Tomcat has support for many of the Java web technologies such as Java Servlet, JavaServer Pages, Java Expression Language and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/01\/install-tomcat-on-ubuntu-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install Tomcat on Ubuntu | Linux Hint&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2226","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=2226"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2226\/revisions"}],"predecessor-version":[{"id":2356,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2226\/revisions\/2356"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=2226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=2226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=2226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}