Archive for the ‘cloud’ tag

Configuring CakePHP on RackSpace Cloud

without comments

CakePHP is a great application framework for “developing rapid websites”. I’ve started building quite a few websites with the system and become quite fond of the MVC framework, the native built-in functionality and vast amount of support available.

When I came to setup an application on RackSpace Cloud Sites (previously known as Mosso), due to the unique way the server was configured (running both Apache and IIS simultaneously), CakePHP didn’t want to work straight out the box.

It was only after quite few hours of research and live chat from the hosting support team that I discovered there were several tweaks that had to be made for CakePHP to work on the Rackspace Cloud.

Basically, it all comes down to the .htaccess files and RewriteBase.

  1. In the route .htaccess file, add the following line:
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    # Cake Defaults
    RewriteRule    ^$ app/webroot/    [L]
    RewriteRule    (.*) app/webroot/$1 [L]
    </IfModule>

  2. In the app folder, add the following line to your .htaccess file:
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /app
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
    </IfModule>

  3. In the app/webroot folder, add the following line to your .htaccess file:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/webroot
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>

That should do it.

Written by Si

November 11th, 2009 at 5:19 pm