Saturday, February 23, 2008

Running Plone behind an apache server

Alhamdullillah.. After a whole night of googling and hacking configurations I was finally able to configure Plone to run behind an apache server. I began my quest by googling and finding this page: http://plone.org/documentation/how-to/apache-ssl . I don't need the ssl mentioned there but I did want to run Plone behind apache. But following the instructions didn't get me any result. So I tried to find out what on earth does the RewriteRule is actually about. After much googling again I found this: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html which also led me to an interesting albeit not really what I'm looking for now at http://httpd.apache.org/docs/1.3/misc/rewriteguide.html. Sooooo... the [P] actually stands for proxy.

Ok.. so now I'm getting somewhere. After much trial and error I finally figured out that I need to run:
sudo a2enmod proxy
sudo a2enmod proxy_http

To enable the proxy function in my apache server. Once that is done, it seems the rules given at the first website is not really correct. So in the end my .htaccess contains the following:
<IfModule mod_proxy.c>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://localhost:8080/$1 [P]
</IfModule>
</IfModule>

But even though that is all fine and dandy, it didn't allow me to surf to more than the front page. All the subsequent links in the page was broken. And I experimented some more until finally I've got it at:

RewriteRule ^(.*) http://localhost:8080/VirtualHostBase/http/abdullahsolutions.com:80/VirtualHostRoot/_vh_plone/$1 [P]


Read the first article and it will mention about enabling Virtual Host Monster in the zope management page. But it did not mention about if you we're actually serving from a directory under your web root. Well, good thing the about page on the zope management page explained it all. So for the example above, my server was serving plone from the directory plone. The _vh_ tells the virtual host monster to append plone/ to every link it generates. Cool stuff..

So then I finally got it working. Alhamdullillah... Took a whole night. But seems to be very worth it.

Update (16 March 2008): Finally I've even got the layout working. After referring to http://matthewwhitworth.com/2008/02/06/escape-from-mod_rewrite/ and the Velo site it point to and also http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#mapfunc which explains what RewriteMap actually does. The RewriteMap part has to be part of the http.conf or if you are using Ubuntu in the sites configuration file. Then escape the request just like it says in the matthewwhitworth site and it all should work. Finally.

4 comments:

Anonymous said...

what a coincidence, I'm having almost the same problem just by a day later ;)

http://www.k4ml.com/node/211

abdza said...

I still haven't gotten it running fully actually. The default layout seems
to be broken. When I try installing NuPlone it works but I like the default
layout better. Hope to find a solution soon.

Anonymous said...

try rewrite witch at http://betabug.ch/zope/witch
tk

abdza said...

Thank you kedai for the tip. But I still can't seem to get it working. I'm not sure where is the problem but the layout is still completely way off. Try to look at http://abdullahsolutions.com/plone. I t seems the css doesn't load at all. And even adding new content it doesn't show up which might point to some problem with apache caching the thing. But I've actually even tried keying in the generated url (http://192.168.0.123:8080/VirtualHostBase/http/192.168.0.123:80/abdsol/VirtualHostRoot/_vh_plone) by hand but it still doesn't display properly although the content is the latest one which might point to the fact that it doesn't go through any apache caching. Have to try it out some more.

Is Blogging No Longer a Thing?

As I embark on my new journey to learn the Rust programming language, I find myself pondering—where have all the blogs gone? In search of pr...