Thursday, November 19, 2009

Wordpress in Tomcat

First download the latest version of the following

1. Tomcat
2. Wordpress
3. Get the latest version of the Quercus, an open source Java implementation of PHP 5 from
4. MySQL Java connector

Steps to install Wordpress in tomcat

1. Extract tomcat
2. Extract Wordpress to tomcat's webapps directory
3. Extract WEB-INF folder from the quercus.war file and put them in tomcat's Wordpress directory
4. Extract mysql connector jar file to wordpress/WEB-INF/lib
5. Go to WEB-INF/web.xml. Check if the following exist

6. Modified the tomcat/conf/web.xml file to the following.

7. Open wordpress/wp-includes/formatting.php. Change the js_escape() function to:

function js_escape($text) {
$safe_text = wp_specialchars($text, 'double');
//$safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text));
//$safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
$safe_text = preg_replace("/\r/", "\n", addslashes($safe_text));
$safe_text = preg_replace("/\n/", "\n", addslashes($safe_text));
return apply_filters('js_escape', $safe_text, $text);

8. Follow to install Wordpress


  1. Hello Sir,
    This is too good.
    I am so happy with this blog.
    This solved my problem.I was searching for same since 2-3 days.

    Thank :)

  2. I am very happy that my notes help you. :)

  3. you are amazing, i just started 10 minutes back and now i was able to start on my website. thanks a lot

  4. I am happy to see this note still helping others after 4 years :)

  5. Thompson - This is PHENOMENAL! You have saved the day for Java PHP integration.

    God bless you!