A word of warning to users of 1and1 and cakePHP

Something I found out recently when I updated the cakePHP core files, when accessing my 1and1 hosting using ssh I kept getting errors when using the cakePHP console. The problem was caused by the fact that by default 1and1 uses PHP 4 for the command line. This cannot be altered using .htaccess, however after a little googleing I found that using php5 on the command line does as you would expect. So to make your cakePHP console work using PHP 5, all that is needed is a little editing of one file. CORE/console/cake

Change this:

exec php -q ${LIB}cake.php -working "${APP}" "$@"

To this:

exec php5 -q ${LIB}cake.php -working "${APP}" "$@"

All console actions will then be run using PHP 5.

7 thoughts on “A word of warning to users of 1and1 and cakePHP

  • November 18, 2010 at 3:56 pm
    Permalink

    Another hint is to include the following lines in your apps top level .htaccess if you want your 1and1 server to allow you to use php5 commands.

    Change ‘/.htaccess’ to:

    AddType x-mapp-php4 .php
    AddType x-mapp-php5 .php
    SetEnv PHP_VER

    RewriteEngine on
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]

    Reply
  • November 18, 2010 at 3:58 pm
    Permalink

    P.S. I came across the above issue and fix after uploading a CakePHP app that was working fine on my server to a client’s 1and1 server and my use of ClassRegistry::init() began throwing errors.

    Reply
  • May 26, 2011 at 2:25 pm
    Permalink

    1and1 has new panel and you can switch on and off with one click right now 😉

    Reply
  • February 1, 2012 at 7:30 am
    Permalink

    Please add

    RewriteBase /

    in your .htaccess file and issue will be resolved.

    Reply
  • December 3, 2012 at 8:18 pm
    Permalink

    Thanks for this Duncan,

    I had a frustrating time sorting this out with cakePHP v2.2 until I found your fix.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *