LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Wordpress and Tomcat (https://www.linuxquestions.org/questions/linux-server-73/wordpress-and-tomcat-4175712089/)

mfoley 05-14-2022 12:12 AM

Wordpress and Tomcat
 
I have Apache http and Tomcat configured on my webserver. I now want to install Wordpress. However, all URL references are currently handled by Tomcat and look for the jsp or html pages in the $CATALINA_HOME/webapps directory.

This link: https://www.linkedin.com/pulse/hosti...biswajit-paria gave some ideas on doing this. It recommended some ideas I'd rather avoid like Quercus.war. This site also said:
Quote:

The simple solution would be to setup tomcat along with LAMP (Linux, Apache, MySQL, PHP) where apache http would serve wordpress blog and proxy server, while tomcat would serve java web application.
That sounds attractive. I could install Wordpress in my Apache DocumentRoot, but I'm not sure how I can access things in the Apache DocumentRoot with Tomcat running. Could this be done with a Virtual Host entry in httpd-vhosts.conf?

Need advice.

bathory 05-14-2022 07:27 AM

Hi,

You can configure apache to use one (or more) vhost(s) to act as a reverse proxy for tomcat and another one (or more) vhost(s) to host your wordpress site(s), i.e. something like this:
Code:

<VirtualHost :80>
ServerName wp.example.com
DocumentRoot /path/to/wordpress
--Rest of directives here--
</VirtualHost>

<VirtualHost *:80>
ServerName tomcat.example.com
ProxyPass  / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
--Rest of directives here--
</VirtualHost>

Regards

mfoley 05-14-2022 10:29 AM

OK, I'll play with that. What if I just deployed wordpress in the Tomcat webapps folder? Would that work? I might try that too, just to see.

bathory 05-14-2022 04:44 PM

Quote:

Originally Posted by mfoley (Post 6353285)
OK, I'll play with that. What if I just deployed wordpress in the Tomcat webapps folder? Would that work? I might try that too, just to see.

I doubt it.
AFAIK tomcat can parse simple php pages, but WP apart from php uses css, js and other stuff that it could be difficult, if not impossible, to use them with tomcat.

boughtonp 05-15-2022 09:04 AM

Quote:

Originally Posted by bathory (Post 6353364)
but WP apart from php uses css, js and other stuff that it could be difficult, if not impossible, to use them with tomcat.

That is nonsense.

Whilst Tomcat is primarily used to run Java servlets, it still includes a perfectly functional HTTP server (Coyote) which can and does serve any static file format you want out of the box without any extra configuration needed for common formats. There is nothing remotely difficult about serving CSS and JS with Tomcat.

(And even if this was somehow not possible, it would still be very easy to serve such files by proxying them through a servlet which generated the appropriate HTTP response.)


Quote:

AFAIK tomcat can parse simple php pages
Tomcat does not parse PHP pages. Like Apache HTTPd and other servers, it simply forwards the requests onto a PHP engine, which is what does the parsing.

In the linked example, the PHP engine is the Quercus servlet - an implementation of PHP on the JVM - which can be used with Tomcat, but is part of Caucho Resin (a different and proprietary server).

Things have possibly changed since I tried getting Quercus running, but many years back I found it not worth the effort.

Quercus is only one option of how to run PHP software via Tomcat server. Another is to use a servlet which implements the FastCGI protocol to connect to PHP-FPM. A quick search reveals jFastCGI does this, but I've never used it so no idea how well it works.

(I prefer Jetty to Tomcat, and Jetty has a built-in FastCGI servlet, which I've successfully used to run both PHP and Python software.)

However, an important thing to keep in mind is that a lot of PHP software expects Apache HTTPd and come with .htaccess files containing rewrite rules and other directives, which then need to be translated to have the software run correctly. (From memory, running Wordpress on Jetty wasn't a big deal, but some of the other CMSes I was testing were very fiddly.)


Anyhow, pairing Apache HTTPd and Tomcat is a common and well-documented process, so unless there's a specific reason to not simply setup a reverse proxy, that should probably be where the effort is focused.



All times are GMT -5. The time now is 06:06 PM.