I am generally a Java programmer (if my day-job is to be believed) and hacking my way through Apache configuration isnt my idea of a fun evening. For some odd reason my trusty old black MacBook hasnt had the best of times when I try to enable “web sharing” and then try executing PHP scripts – all I get is a dump of the source. Time for a creative solution to the problem!
The folks that created the Resin App Server have a 100% Java implementation of PHP 5 released under the Open Source GPL license, known as Quercus. So step 1 was to download the latest release that will run on non-Resin app servers: quercus-4.0.1.war.
This was the point where I also realized that I dont have an up-to-date install of Apache Tomcat on my system either. Step 2 was to go download Tomcat 6.0.20 and install it.
Many applications need to know where Tomcat lives, and that means setting the CATALINA_HOME environment variable to point to the install. In a terminal I edited the global startup file for the terminal: sudo vi /etc/bashrc to add the line:
CATALINA_HOME=/Users/paul/Documents/Devt/3rd-party/apache-tomcat-6.0.20
Step 3 was to $CATALINA_HOME/bin/startup.sh to start tomcat and then point a browser at http://localhost:8080/quercus-4.0.1/ where I saw confirmation that all was well:
Testing for Quercus™…
Congratulations! Quercus™ Open Source 4.0.1 is interpreting PHP pages. Have fun!
I didnt like the URL though, but that’s easily changed. I simply nuked the quercus-4.0.1 directory under $CATALINA_HOME/webapps and renamed the Quercus WAR file “php.war”. I bounced Tomcat and bingo – a “php” directory I could drop files into. As a final test, I created info.php
<?php
phpinfo();
?>
and hit it on the pretty URL: http://localhost:8080/php/info.php. All displayed correctly. I was off and rolling running PHP on top of Apache Tomcat! Stay tuned for Part II – getting WordPress running on top of PHP running on Tomcat!
This is deeply wrong on so many levels!
*cringe*
In your apache’s httpd.conf you need these things
LoadModule php5_module modules/libphp5.so
DirectoryIndex index.php index.html
(inside the dir_module ifModule condition)
and, most importantly (and the one you probably missed:
AddType application/x-httpd-php .php
in the mime_module ifModule condition
I bet you use a sledgehammer for your screws, don’t you.