{"id":3815,"date":"2019-09-15T12:20:21","date_gmt":"2019-09-15T00:20:21","guid":{"rendered":"http:\/\/www.zoyinc.com\/?p=3815"},"modified":"2019-09-15T12:20:21","modified_gmt":"2019-09-15T00:20:21","slug":"installing-tomcat-9-behind-apache-on-centos-7","status":"publish","type":"post","link":"http:\/\/www.zoyinc.com\/?p=3815","title":{"rendered":"Installing Tomcat 9 behind Apache on CentOS 7"},"content":{"rendered":"<p>There are a number of posts on how to do this. I have created this post mostly for my own records so I know I will continue to have a record of what I have done.<\/p>\n<h1>Setup<\/h1>\n<p>Ensure you have at least JDK 8, I have the RPM &#8220;java-1.8.0-openjdk.x86_64&#8221; installed by this point.<\/p>\n<p>Create a system user account to run tomcat:<\/p>\n<p style=\"padding-left: 30px;\">useradd -r tomcat &#8211;shell \/bin\/false<\/p>\n<p>Download the Tomcat 9 zip file, in my case this was &#8220;apache-tomcat-9.0.22.zip&#8221; which I downloaded to &#8220;\/var\/tmp&#8221; and then extract it and set permissions:<\/p>\n<p style=\"padding-left: 30px;\">cd \/var\/tmp<br \/>\nunzip apache-tomcat-9.0.22.zip -d \/opt<br \/>\nmv \/opt\/apache-tomcat-9.0.22 \/opt\/tomcat9<br \/>\nchown -R tomcat.tomcat \/opt\/tomcat9<\/p>\n<p>Now create a service file:<\/p>\n<p style=\"padding-left: 30px;\">\/etc\/systemd\/system\/tomcat.service<\/p>\n<p>For me this looked like:<\/p>\n<pre class=\"lang:sh decode:true\">[Unit]\r\nDescription=Apache Tomcat 9\r\nAfter=syslog.target network.target\r\n\r\n[Service]\r\nUser=tomcat\r\nGroup=tomcat\r\nType=forking\r\nEnvironment=CATALINA_PID=\/opt\/tomcat9\/tomcat.pid\r\nEnvironment=CATALINA_HOME=\/opt\/tomcat9\r\nEnvironment=CATALINA_BASE=\/opt\/tomcat9\r\nExecStart=\/opt\/tomcat9\/bin\/startup.sh\r\nExecStop=\/opt\/tomcat9\/bin\/shutdown.sh\r\nRestart=on-failure\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n<p>Now set the correct permissions for the Tomcat startup script, enable the service and finally start the service:<\/p>\n<p style=\"padding-left: 30px;\">cd \/opt\/tomcat9\/bin<br \/>\nchmod 774 *.sh<br \/>\nsystemctl enable tomcat.service<br \/>\nsystemctl start tomcat.service<\/p>\n<p>At this point Tomcat is running and you should be able to access it on port 8080 so:<\/p>\n<p style=\"padding-left: 30px;\">http:\/\/centos7-base:8080\/<\/p>\n<h2>References<\/h2>\n<p>Rose Hosting: Install Tomcat 9 on CentOS 7<br \/>\n<a  href=\"https:\/\/www.rosehosting.com\/blog\/install-tomcat-9-on-centos-7\/\">https:\/\/www.rosehosting.com\/blog\/install-tomcat-9-on-centos-7\/<\/a><\/p>\n<p>Red Hat: Creating and Modifying systemd Unit Files<br \/>\n<a  href=\"https:\/\/access.redhat.com\/documentation\/en-us\/red_hat_enterprise_linux\/7\/html\/system_administrators_guide\/sect-managing_services_with_systemd-unit_files\">https:\/\/access.redhat.com\/documentation\/en-us\/red_hat_enterprise_linux\/7\/html\/system_administrators_guide\/sect-managing_services_with_systemd-unit_files<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a number of posts on how to do this. I have created this post mostly for my own records so I know I will continue to have a record of what I have done. Setup Ensure you have at least JDK 8, I have the RPM &#8220;java-1.8.0-openjdk.x86_64&#8221; installed by this point. Create a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":848,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,553,552],"tags":[305,555,309,295,6,94,162,93],"class_list":["post-3815","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","category-centos","category-redhat","tag-apache","tag-centos","tag-java","tag-linux","tag-redhat","tag-setup","tag-tomcat","tag-unix"],"_links":{"self":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/3815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3815"}],"version-history":[{"count":5,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/3815\/revisions"}],"predecessor-version":[{"id":3881,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/3815\/revisions\/3881"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/media\/848"}],"wp:attachment":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3815"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}