I know this question might be similar to others, however, I haven’t been able to solve this.
I have a server with 25 websites, all of them uses Tomcat. I’m migrating to a new server which has Tomcat 8 (the regular version), whereas the old server uses “CPanel’s easy tomcat”.
I started migrating one website, which is now running on the new server, however, when a JSP is called from the browser, the browser shows the JSP code instead of executing it.
In my old server, I had to execute a feature from CPanel’s easy-tomcat called “install servlets”, which I really don’t know what it does, however, after executing that, Tomcat would execute JSP’s.
Now, in my new server, accordgin to what I’ve read, I’ve added this to the %CATALINA_HOME%/conf/server.xml file, inside the <Engine></Engine>
tags (which I also had to include in my old server):
<Host name="mydomain.com" appBase="/home/myAccName/public_html/">
<Context path="" reloadable="false" docBase="/home/myAccName/public_html" />
</Host>
As you can see, the application is not located under %CATALINA_HOME%/webapps/ directory, and that’s the way I need it to be.
What am I missing?
Any help will be really appreciated
I’m using Tomcat 8, EasyApache 4 and CentOS 7.6
3
Answers
This is the way I managed to solve this. I don't know if it's the best way, but it works. Just follow the next 3 steps:
1) In %CATALINA_HOME%/conf/server.xml:
2) Then I had to add a file: %CATALINA_HOME%/conf/mydomain.com/ROOT.xml
Then on the Apache side, I had to configure the mod_proxy_ajp connector
I've edited the file:
3) /etc/apache2/conf.d/userdata/std/2/accountfolder/mydomain.com/cp_jkmount.conf
My application/website is located on /home/accountfolder/public_html/ and there's nothing on the %CATALINA_HOME%/webapps/ directory. For me this is better since I can upload a jsp or whatever directly where the app is located using a FTP user.
If you have any trouble, check the folder permissions and owners in your /home/accountfolder/public_html/ directory, Tomcat needs permissions for reading/executing etc. A Tomcat's 404 error will be shown if Tomcat can't access those files & folders.
As I mentioned in this post, my app is "exploded" (if that's the correct term), I mean, it's NOT packed in a WAR file.
check that the following in in your tomcat/conf.web.xml file
You can create VirtualHosts to setup multiple websites with multiple domain names in one server. You can try out same in tomcat 7, 8 and in 9 as well.
1.Edit your relevant server.xml file and include Virtual hosts as below.
Make sure to restart your tomcat server for the applied changes to take effect.
Explanation
For example.com domain, /opt/tomcat/webapps/myapp1 is the document root (for your web 1).
For mydomain.org domain, /opt/tomcat/webapps/myapp2 is the document root(for your web 1).