Almost Perfect Rackspace Cloud .htaccess for PHP

Dear Reader(s?)

If you use Rackspace Cloud hosting you’ll recognise that thier PHP configuration is gash and you’ll be pulling your hair out trying to figure out why *some* ini_sets fail and sessions just don’t work at all, making you miserable. If you’re not and your hair is intact, good for you.

I learnt through trial and error so here’s what my current .htaccess file for Rackspace looks like

One thing to note is I use the Zend Framework alot, hence the write rules.

#Zend Framework Specific.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

php_value session.gc_probability 1
php_value session.gc_divisor 100
php_value session.gc_maxlifetime 3600
php_value session.save_path /mnt/stor1-wc2-dfw1/654321/12356/www.sitename.com/web/sessions

php_value max_execution_time 3600
php_value upload_max_filesize 100M
php_value post_max_size 220M
php_value memory_limit 256M
php_value magic_quotes_gpc Off

So bit sucky that you have to do that, but credit where credit is due, their live chat support is great. Instant answers to anything you can’t find in their cloud hosting wiki.

Another quality reference page to check is the .htaccess faqs page too, before you start buggin their support agents ;)

Advertisement

8 Responses to Almost Perfect Rackspace Cloud .htaccess for PHP

  1. Pingback: Twitted by jameshd

  2. Edward Savage

    I noticed that your setting:
    php_value magic_quotes_gpc Off

    Differed from mine:
    php_flag magic_quotes_gpc Off

    So I checked and found this in the PHP manual:
    “Note: Don’t use php_value to set boolean values. php_flag (see below) should be used instead.”
    http://php.net/manual/en/configuration.changes.php

  3. Edward Savage

    Two more things that might help:
    1) Time zone setting:
    php_value date.timezone America/New_York

    2) Apache compression:
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript

  4. Pingback: 2010 in review | jameshd – web ramblings

  5. Hello, i a m trying to run a zend application in Rackpace CloudSites and has followed your instructions but got no luck. Browser gets into a loop when requesting index.php.
    I have published the .htaccess and index.php in the “content” folder and created “application” and “library” folders at the same level than “content”.
    Any idea if there is any additional configuration i need to set?
    Thank you

    • This is down to your application itself. It’s not a cloud problem unfortunately. I’d make sure all your paths are correct in your index.php to places like your application dir and library dir! Double check those :)

  6. the rewritebase rule saved my arse. Never needed that on other hosting providers.
    Now I’m still wondering why

    RewriteRule !.(js|css|ico|gif|jpg|png)$ index.php

    doesn’t work but I’m optimistic now to find the answer.
    Thanks buddy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s