Thursday, 16 February 2012

Configuring MODx to run under Tomcat

If you read my article on running PHP under tomcat and debugging it using eclipse you should be up to speed on getting PHP running under Tomcat. An earlier post detailed how to set up Drupal on Tomcat.
This is exactly the same deal!
SO these are the steps:
  1. Set up a folder for your MODx site as a Tomcat Web project where your website folder is "htmldocs" (as it helps you when referring to MODx documentation).
  2. If you have an install of a MODx site which is running under Apache this part is a doddle.
    Simply place ALL the site files into the htmldocs folder.
  3. Start up Tomcat;
  4. Browse to the site & hurah you see your site!
  5. However if you have an index.html file in your root folder you may not see it if index.html comes before your index.php in your welcome file list.
    Either adjust your welcome list or delete the index.html file.
  6. Now when you browse to your index.php page you will see your site.
    Assuming you have your db permissions set up for the web user.
    The php debugging here is a great way to find out where to look as ModX kindly tells you the file and line number where the db access is.
  7. HOWEVER at this point you will find you can see index.php and any other php pages but ModX generates URLs with a .html extension which Tomcat just says do not exist.
    These are " Friendly URLs" in MODx talk.
    This is similar to problems that people running under Apache Httpd encounter.
    If you look for your page on the admin pages (See picture).

    Each page has a number Home=1, "About Us"=12, Solutions=2.
    Yo should be able to get to the pages in question by using the URL <site path>/index.php?id=<doc number>.
    As does using the URL alias seen when editing the resource which is the file refered to by the "Friendly URLs". Try the URL <site path>/index.php?q=<freindly html doc name> (ie. <site path>/index.php?q..
  8. SO lets fix this so the  "Friendly URLs" work.
    We can turn them off but then they are not SEO, having this feature is arguably the most powerful way to have MODx change your urls. When you're using this method, your MODx pages will look and feel just like they were uploaded into a directory on a web server. This is good news for bookmarking and SEO.
    To do this you have to edit your .htaccess file.
    The first hitch will be editing it as eclipse just hides this resource (fix here).

1 comment:

  1. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
    Java Training in Chennai

    ReplyDelete