How to run PHP5 on 1and1.com in 1 easy step…

It actually can’t get any easier than this.

Just put the following line in your .htaccess file:

AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

And your done! Your site is now running under PHP5.

Enjoy…


Want proof? Want to know details?

Well… Here you go…

It turn’s out that 1and1.com accounts all come with PHP4 active. By default php files are processed by PHP Version 4.4.2.

Test this out on your 1&1 server without affecting the operation of your site:

Create a new directory called TestPHP4

Create a file in that folder called index.php that contains the following text

[php]

phpinfo();
?>

[/php]

Then open that directory in your web browser.

You’ll get something that looks like this:

PHP Logo

PHP Version 4.4.2

System Linux infong 2.4 #1 SMP Wed Jan 18 14:53:29 CET 2006 i686 unknown
Build Date Feb 6 2006 10:16:02
Configure Command ‘../configure’ ‘–with-pear’ ‘–with-mysql=/usr’ ‘–with-zlib’ ‘–enable-debug=no’ ‘–enable-safe-mode=no’ ‘–enable-discard-path=no’ ‘–with-gd=/usr’ ‘–with-png-dir=/usr/lib’ ‘–enable-track-vars’ ‘–with-db’ ‘–with-gdbm’ ‘–enable-force-cgi-redirect’ ‘–with-ttf=/usr/’ ‘–enable-ftp’ ‘–with-mcrypt’ ‘–enable-dbase’ ‘–enable-memory-limit’ ‘–enable-calendar’ ‘–enable-wddx’ ‘–with-jpeg-dir=/usr/src/kundenserver/jpeg-6b’ ‘–enable-bcmath’ ‘–enable-gd-imgstrttf’ ‘–enable-shmop’ ‘–enable-mhash’ ‘–with-mhash=/usr/src/kundenserver/mhash-0.8.9/’ ‘–with-openssl’ ‘–enable-xslt’ ‘–with-xslt-sablot’ ‘–with-dom’ ‘–with-dom-xslt’ ‘–with-dom-exslt’ ‘–with-imap’ ‘–with-curl’ ‘–with-iconv=/usr/local’ ‘–with-freetype-dir=/usr/include/freetype2’ ‘–with-bz2’ ‘–with-gettext’ ‘–enable-exif’ ‘–with-idn’ ‘–enable-mbstring=all’
Server API CGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/lib/php.ini
PHP API 20020918
PHP Extension 20020429
Zend Extension 20050606

Now copy and rename the TestPHP4 directory as TestPHP5 (or create the directory as above manually). Now create one more file in the TestPHP5 directory named .htaccess

Make certain a period is in front of htaccess like this: .htaccess

The period indicates this it is a hidden file. It tells your system how to process requests. In this case we will tell it to process all .php files as php5 files. That is done by adding the following line:

AddType x-mapp-php5 .php

Now save that file and browse to the directory with your web browser. You’ll see something like the following:

PHP Version 5.1.4

System Linux infong371 2.4.28-grsec-20050113a #1 SMP Thu Jan 13 08:59:31 CET 2005 i686
Build Date May 4 2006 13:56:29
Configure Command ‘../configure’ ‘–program-suffix=5’ ‘–with-pear=/usr/local/lib/php5’ ‘–with-config-file-path=/usr/local/lib/php5’ ‘–with-libxml-dir=/usr/local/php5’ ‘–without-sqlite’ ‘–with-config-file-scan-dir=.’ ‘–with-mysqli=/usr/local/mysql/bin/mysql_config’ ‘–enable-soap’ ‘–with-xsl=/usr/local/php5’ ‘–enable-mbstring=all’ ‘–with-curl=/usr/local/php5’ ‘–with-mcrypt=/usr/local/php5’ ‘–with-gd’ ‘–with-pdo-mysql=/usr/local/mysql’ ‘–with-freetype-dir’ ‘–with-libxml-dir=/usr/local/php5’ ‘–with-mysql=/usr/local/mysql’ ‘–with-zlib’ ‘–enable-debug=no’ ‘–enable-safe-mode=no’ ‘–enable-discard-path=no’ ‘–with-png-dir=/usr/lib’ ‘–enable-track-vars’ ‘–with-db’ ‘–with-gdbm’ ‘–enable-force-cgi-redirect’ ‘–with-ttf=/usr/’ ‘–enable-ftp’ ‘–enable-dbas’ ‘–enable-memory-limit’ ‘–enable-calendar’ ‘–enable-wddx’ ‘–with-jpeg-dir=/usr/src/kundenserver/jpeg-6b’ ‘–enable-bcmath’ ‘–enable-gd-imgstrttf’ ‘–enable-shmop’ ‘–enable-mhash’ ‘–with-mhash=/usr/src/kundenserver/mhash-0.8.9/’ ‘–with-openssl’ ‘–enable-xslt’ ‘–with-xslt-sablot’ ‘–with-dom’ ‘–with-dom-xslt’ ‘–with-dom-exslt’ ‘–with-imap’ ‘–with-iconv=/usr/local’ ‘–with-bz2’ ‘–with-gettext’ ‘–enable-exif’ ‘–with-idn’
Server API CGI
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/lib/php5/php.ini
Scan this dir for additional .ini files .
PHP API 20041225
PHP Extension 20050922
Zend Extension 220051025

You now have two different directories that process files using two different php engines.

Pretty cool huh?

  • j2ee

    Thanks pal much appreciated – great tip. saved me a lot of time

  • ugabuga

    Hey thanks man. I called 1and1 and they insisted that mysqli wont work unless i get a dedicated server. This is a great tip. I didnt even notice it defaults to php4.

  • CT

    ugabuga: that’s a stock response from 1and1’s support drones. Part of the reason I’m going to dump them shortly.

    The other part of the reason: This recent php5 upgrade has, predictably, killed my site with incessant “cgi-limits reached” error messages (an obviously false result). I’m going to try this .htaccess fix tonight, assuming I can find a brief window in which to actually access the site. Hope it works. Regardless, I’ve had it with 1and1 — every time they inflict a change, I have to scramble, and they NEVER accept responsibility for the problems.

  • Interesting, what changes have you run afoul of before? I’ve not noticed them update much of anything I care about at all…

    My question would be, if you are running still php4 how did the update have any affect? Did they make other change?

  • pear

    but if you type
    php -v
    In the command line, you will get php 4.4.1

    which one tell you the truth? phpinfo() or command line?

  • Both!

    The default PHP processor IS 4.4.1. and that’s what you get when you run php directly from the command line.

    However, when a request comes through the http: interface, Apache will see the over-ride and send it to the newer release.

    So, both are telling the truth, because you are asking two different questions.

    Hope that helps

  • Pingback: elliptical . . . : Blog Archive : links for 2007-05-20()

  • JTS

    The “AddType” rule works great for non-secured sites on 1and1.com, but NOT secured sites. From one of the “support” people at 1and1 (I use the word “support” lightly).

    “The AddType rule will not work when accessing through https. You will
    need to rename any scripts that should be parsed in PHP 5 to end in
    .php5.”

    I ended up renaming everything to get it to work. Ridiculous actually.

  • Oh, how interesting… I’m not buying the “simply doesn’t work” answer. There’s more to it then that, I’m sure. How do you have your https configured. Are you using your own certificate or the shared one? This is something I’ve not yet played with on these servers. I bet there is a deeper answer to your problem.

  • jts

    Brian, the cert came with the developer package. I used the default setup procedures that 1and1.com provides.
    My entire web-app was built in PHP5. It works great with the .HTACCESS file in non-secure mode. As soon as you switch over to the good ol’ HTTPS, it bombs miserably. I’ve tried renaming some of the files to be .PHP5 and it does actually work. Its just frustrating that the .HTACCESS file does not work in HTTPS mode. 1and1 usually hasn’t given me any grief, but if they are going to support PHP5 AND provide documentation demonstrating the .HTACCESS file, they should definetly make it clear that it will not work in Secure mode.

  • Oh, I understood that, I just don’t understand why secure mode has any thing do do with it unless it is somehow first being processed through a seperate server…

  • JTS

    hehe. That’s the million dollar questions (or 14.95 a month). Thank God I built the system in a relatively modular fashion, as I only had to change the names of the business processing scripts. (http://EverythingFreight.com if you are interested).

  • bluefish

    Hiya – I had the same issue on 1and1 – using the SSL certificate that comes integrated with their accounts – https seemed to just the AddType from working.

    I used phpinfo to check – and the https server did default back to PHP4.

    So I added AddHandler x-mapp-php5 .php to my .htaccess … and way hay everything is back to php5 ๐Ÿ™‚

    Another way round this is to use their free ssl relay service which seems to keep everything working happily on PHP5 – but you do end up with an ugly url …
    In 1and1 control panel – in admin / domains select which domain you want to register with their relay server then just use
    https://sslrelay.com/

    Hope that helps someone …

  • Rail

    In .htaccess put:

    AddType x-mapp-php5 .php

    AddHandler x-mapp-php5 .php

    seems to work on our secure site

  • jts

    Rail….

    Tried it and used a specific PHP5 test (hello world with a try/catch) and it seemed to work. Not sure why the help desk didn’t offer that up! Will have to do more testing to double check it is working.

  • There is a link somwhere in 1and1’s help desk but it is buried really deep in there. I thought about taking down this post when I saw it was there but then I figured that if I couldn’t find it till I knew what to look for, others were probably in the same boat. Glad this worked for you!

  • Lon

    works fantastic, but any chance you know why something keeps rewriting my htaaccess file and removing those lines?

  • jts

    Probably one of their automated tools? Did you password protect any directories or use any other 1and1 web tools to manage your account?

  • James

    Thanks so much man! As soon as I needed PHP 5 and found it was not the default, I got a little worried, but one quick search and alas I found your tip! You’ve saved the day for me! Keep up the great work!

  • For those of you who are anti 1and1, what host would you suggest as an alternative (and don’t say godaddy) ? I have been relatively pleased with 1and1 until I tried using the Zend Framework with it and it has just been a confusing mess.

  • travis

    Thanks for the tip, I had AddType x-mapp-php5 .php already in my .htaccess and experienced the issue with it defaulting to php4 when using SSL. I added the line AddHandler x-mapp-php5 .php and it worked great!! thanks for saving me from renaming all my php files!

  • Craig

    @Michael

    A Small Orange offers both PHP4 and PHP5. SSL works with no gimmicks.

    http://www.asmallorange.com/

  • There are two that I have experience with and would personally recommend. They are in no particular order, ServerBeach.com and DreamHost.com.

    Server Beach is VERY WordPress friendly and I’ve met them and wear their shirts. We host some machines with them for b5media. In fact I should make certain I put one of their stickers on my laptop.

    DreamHost.com is well named. You will not be unhappy with them. They have a great group of people and their tech team is top knotch. They had a recent billing snafu, that went spiraling south quickly as they quickly swung the other way sending out refunds where none were due. Through this whole thing, they handled the issues quite openly and professionally. The fact of the matter is that stuff happens. What you do about it shows your character and how Dreamhost handled this proved everything I’d always suspected about them when I looked at them from a distance. And I would proudly wear one of their shirts too if I had one. ๐Ÿ˜‰

  • THX very much for the tipp.

    Since 1and1 changed something on their hosting enviroment my gallery2 and wordpres just gave up working. Just with these two tiny lines everything is fine now.

    2 thumbs up ๐Ÿ™‚

  • Thank you so much – this really helped us out – all fixed now at http://www.empdesigns.co.uk

  • Jim

    Thanks! I just created a file in my root directory called “testphp.php” and opened that in my browser after editing my .htaccess … Worked great.

  • I recently had a problem where on the 1and1 shared hosting setup my web site was hacked and started happily serving malware, I pulled the site asap and fortunately it was not the main one although it was the blog, being mighty peeved I wrote stinking email to the support diversion (deliberate pun) and they came back that I should have the addtype, my attitude is it is a shared server you morons you look after it.

    Fact is if any site gets hacked because it is a weakness in the php (the 1and1 support techy’s words not mine) it will infect the rest of the physical machine depending on how securely that is setup, or not in this case. I had to manually go through every sungle table and sql query to find the little bugger.

    Anyway I have the same problem and I found out that 1and1 was to blame for another clients problems when they used the cgi only version instead of doing a proper install of php.

  • Hello, Dreamhost is expensive , high cost and very, very, very slow.
    Too much services (ssh, great shell but very slowly).
    Itยดs very no proffesional.

  • Pingback: Kalvan.org » Blog Archive » Irony()

  • The infos here helped me to sort out my problems with NGG for WP – cool thanks

  • Pingback: random gallery hell | ownage()

  • Pingback: dmacias . org : Moving away from PHP 4 to PHP 5()

  • Thanks for this, especially the explanation.

  • thombaugh

    pretty durn cool. thx

  • Charles

    My limited words can’t express how appreciative I am for this article.

    I found this site after spending stressful and frustrating hours with 1and1 support to noavail.

    I am glad to note that after following your recommendation regarding the 500 Error message and WordPress my problem went away INSTANTLY. I wish I had Google search earlier instead of spending countless hours with 1and1.

    Thanks

  • DuWolfy

    You my friend are a star, consistant ” you are not running PHP 5.0 ” errors.

    Followed your instructions and my woe’s are gone.

    again my thanks

  • PHP at 1and1 from the command line defaults to PHP4 so running this still uses the older version”

    ./envinfo.php5

    To get the command line to use PHP5, use this instead.

    php5 envinfo.php5

  • Pingback: mux.awardtour — award tour()

  • I am hosting with 1and1, I did not have .htaccess before and i created one with two line to support php5

    AddType x-mapp-php5 .php
    AddHandler x-mapp-php5 .php

    I also created file phpver.php in the same directory as .htaccess when i invoke the file from browser it now prompts me to save the file. The file downloaded had the actuall php code. What am i doing wrong.

  • Well that looks OK… Obviously your .htaccess is being processed as .php files are no longer being processed as they were before. However, it would seem that your server doesn’t have the x-mapp-php5 type defined… I don’t know why that would be… Does anyone else on this comment list have any suggestions?

  • To follow-up on my previour comment, the file download was triggered on wordpress admin site only. My blog is working fine with the php5 entries.

    I am using wordpress 2.6 so i guess this is compatible with php5, is there any additional config?

  • Michael

    Thanks, this just saved me a lot of time. php5 is required for the twitter module in drupal6.

  • Wow! f’ing amazing dude! I was trying to test out Elgg and I wasn’t able to run it till I came across your article. thanks a bunch man you rock.

  • Daniel

    This works!! you are the man!!!!!

  • THANK YOU! Your instructions worked perfectly and saved me HEADACHES and TIME!

    BIGTIME!

  • Tom

    Thanks!

  • Pingback: JoomFish PHP problems with Joomla 1.5 « Wuwei2k2 Blog()

  • Pingback: WordPress, shared hosting and 500 errors | spacerdotgif()

  • Hi,

    I am trying to install Elgg 1.2 on lunarpages shared hosting and i get following errors :

    Parse error: syntax error, unexpected T_NEW in /home/postp4/public_html/engine/start.php on line 95

    Also i once got 505 internal server error. I am trying to install straight to root in public_html folder.

    thanks

  • Rahul, I do have Elgg 1.2 running on a 1and1 share system. Elgg uses .htaccess to generate dynamic URLs.

    1. Make sure you have .htaccess with AddType x-mapp-php5 .php
    AddHandler x-mapp-php5 .php

    2.Double check the path for the data folder – The full path to the directory where uploaded files will be stored, followed by a trailing slash:

    3.Checkout the ff: http://docs.elgg.org/wiki/Installation

  • Thanks! That’s exactly what I needed

  • Pingback: Installation error: Fatal error: main() [function.require] | Page 2 | Pligg CMS Forum()

  • Koz

    Thanks a lot! that worked perfectly! I didn’t even realize you could make an .htaccess file and get it to run on 1&1! Thanks again!

  • Aaron

    Thanks! This worked perfectly.

  • I followed the instructions and it still shows PHP4.49 in the Testphp5 directory. Does it take some time to update?

  • No it is instantaneous.

    Back in 2006 when I wrote this, they hadn’t documented how to do it. They have now, but and the method hasn’t changed:

    http://faq.1and1.com/scripting_languages_supported/php/5.html

  • Now, there are hundreds of programs available ranging from free to hundreds of dollars, including
    everything from a bare bones setup to an all inclusive image editing suit.
    It’s a good idea to have separate email promotions for prospects and customers, too, because you typically need to send different information to the different groups. Therefore it’s better to always do the intelligent point and take these tips.