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

July 13, 2006

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?

Share and Enjoy:
  • del.icio.us
  • Fark
  • Reddit
  • Digg
  • DZone
  • email
  • Facebook
  • FriendFeed
  • Google Bookmarks
  • Netvibes
  • Ping.fm
  • Posterous
  • Slashdot
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Yahoo! Bookmarks
  • Add to favorites
  • Blogosphere News
  • HackerNews
  • Identi.ca
  • LinkedIn
  • MySpace
  • Print
  • Yahoo! Buzz

Comments

54 Responses to “How to run PHP5 on 1and1.com in 1 easy step…”

  1. j2ee on August 21st, 2006 6:01 pm

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

  2. ugabuga on November 25th, 2006 1:04 pm

    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.

  3. CT on December 13th, 2006 12:52 pm

    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.

  4. Brian on December 14th, 2006 5:38 pm

    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?

  5. pear on May 16th, 2007 2:11 pm

    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?

  6. Brian on May 16th, 2007 2:42 pm

    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

  7. JTS on June 4th, 2007 11:43 pm

    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.

  8. Brian on June 5th, 2007 6:42 am

    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.

  9. jts on June 5th, 2007 2:01 pm

    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.

  10. Brian on June 5th, 2007 3:00 pm

    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…

  11. JTS on June 6th, 2007 9:49 pm

    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).

  12. bluefish on June 29th, 2007 7:20 am

    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 …

  13. Rail on October 29th, 2007 4:56 pm

    In .htaccess put:

    AddType x-mapp-php5 .php

    AddHandler x-mapp-php5 .php

    seems to work on our secure site

  14. jts on October 29th, 2007 5:10 pm

    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.

  15. Brian on October 30th, 2007 1:11 am

    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!

  16. Lon on November 30th, 2007 4:44 pm

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

  17. jts on November 30th, 2007 4:47 pm

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

  18. James on January 21st, 2008 5:39 pm

    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!

  19. Michael Ray on February 9th, 2008 1:36 pm

    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.

  20. travis on February 14th, 2008 9:36 pm

    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!

  21. Craig on February 16th, 2008 1:03 am

    @Michael

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

    http://www.asmallorange.com/

  22. Brian on February 21st, 2008 5:48 pm

    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. ;)

  23. Hendrik on March 26th, 2008 11:26 am

    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 :-)

  24. Emily on April 17th, 2008 4:27 am

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

  25. Jim on April 22nd, 2008 7:09 pm

    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.

  26. Hilary on May 21st, 2008 12:40 pm

    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.

  27. Oscar on June 19th, 2008 5:43 pm

    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.

  28. countzeero on July 29th, 2008 1:59 pm

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

  29. Nathan on August 6th, 2008 9:47 am

    Thanks for this, especially the explanation.

  30. thombaugh on August 9th, 2008 4:41 pm

    pretty durn cool. thx

  31. Charles on August 21st, 2008 2:21 am

    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

  32. DuWolfy on August 21st, 2008 8:39 pm

    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

  33. David Fordham on October 2nd, 2008 7:21 am

    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

  34. Sameer Dhoot on November 13th, 2008 11:38 am

    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.

  35. Brian Layman on November 13th, 2008 12:22 pm

    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?

  36. Sameer Dhoot on November 13th, 2008 2:29 pm

    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?

  37. Michael on November 21st, 2008 11:42 am

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

  38. Victor on November 23rd, 2008 6:21 pm

    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.

  39. Daniel on January 13th, 2009 3:31 pm

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

  40. David on January 21st, 2009 2:31 pm

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

    BIGTIME!

  41. Tom on January 28th, 2009 1:05 am

    Thanks!

  42. Rahul Malik on February 3rd, 2009 3:53 pm

    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

  43. Burnedbrass on February 3rd, 2009 8:09 pm

    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

  44. Metricula on February 3rd, 2009 9:44 pm

    Thanks! That’s exactly what I needed

  45. Koz on March 3rd, 2009 8:14 pm

    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!

  46. Aaron on April 25th, 2009 1:46 am

    Thanks! This worked perfectly.

Got something to say?





Who is Brian Layman

I am a WordPress expert living in North East Ohio. I am part of the ever expanding Open Source Internet workforce. I am able to stay at home, with my wife and four home schooled kids, while working as the Senior Developer for b5media - a blogging network that has hosted over 300+

I co-host the NEO WordPress Monthly meetup. I am the board chair of our local church. I host and have provided development services for clients such TV personalities Rhett and Link as well as corporations such as Borland International.

In my spare time I try to sneak out, canoe, mountain bike and camp as often as I can. Sometimes I also defend the earth against zombies and aliens, but usually not during the camping trips.

Services Provided

In providing hosting, email, theme and plugin development to my clients, I function as a single point of contact answering to the needs of their expanding sites.

My service portfolio includes but is not limited to WordPress hosting, optimization, theme development and custom plugin creation. Community creation via vBulletin, Ning and BuddyPress and bbpress

I also am well experienced in site conversion, transition and merges. To clarify this, website technologies change and giving up your data is not an option. I have transitioned literally hundreds of sites from one platform to another.

viagra 50 mg indian version of viagra cialis cheapest viagra india online viagra cost comparison viagra for sale without prescription generic tadalafil online buy viagra in korea indian levitra discount cialis online viagra prescription over the counter vardenafil cialis otc cialis no rx cialis 30 mg viagra ranbaxy buy levitra in uk cialis low price tadalafil tablets 10mg cheap viagra fast shipping cheap generic levitra cialis discount cialis 5mg viagra discount prices buy levitra without prescription vardenafil online generic levitra canada viagra professional price cheapest sildenafil citrate indian version of cialis viagra lowest price viagra online prescriptions tadalafil 10mg levitra over the counter levitra prescriptions online buy viagra without a prescription liquid tadalafil citrate buy viagra prescription online tadalafil 20mg india india viagra generic sildenafil citrate for sale vardenafil hcl 10mg cialis discount coupon buy levitra australia viagra over the counter in canada liquid sildenafil tadalafil price comparison viagra cost in india cialis mail order sildenafil sales buy vardenafil cialis offer cheap vardenafil generic cialis no prescription viagra tabs generic indian names viagra price canada vardenafil hcl 20 mg generic viagra without prescription viagra by scilla biotechnologies buy generic cialis free viagra viagra over the counter viagra pills kamagra 100 mg cialis from india tadalafil australia tadalafil 20mg tablets tadalafil soft tabs sildenafil pills viagra no prescription required generic viagra paypal tadalafil online indian viagra cost tadalafil online pharmacy generic soft viagra sildenafil soft tablets viagra generic names buy viagra in ireland levitra without prescription levitra online purchase cialis pill indian tadalafil levitra 5mg cialis cost per pill tadalafil oral jelly sildenafil no prescription vardenafil price generic cialis 10mg cheap cialis no prescription order sildenafil citrate indian generic viagra blue viagra buy cialis usa apcalis 20mg tablets viagra overnight delivery sildenafil india purchase viagra without a prescription viagra prescriptions order viagra without prescription viagra with no prescription levitra for sale purchase viagra canada discount levitra viagra 200mg cheap viagra 100mg cialis overnight delivery buy sildenafil online viagra made in india cialis tabs 10mg viagra indian pharmacy viagra for sale in ireland viagra uk prices buy viagra in europe generic cialis india levitra online viagra for sale india buy viagra in dublin generic cialis soft tabs viagra 50mg cost generic sildenafil 100mg tadalafil generic viagra super active 100 mg kamagra 100mg sildenafil 100 mg tablets cialis no prescription viagra low price online cialis suhagra tablets buy cialis daily use tadalafil sample cialis prices viagra prescription online buy cialis pill kamagra from india cialis online levitra mg vigora india vardenafil 10 mg sildenafil citrate 100mg buy viagra in india buy cialis professional viagra in india buy viagra in singapore generic revatio viagra substitutes sildenafil canada viagra no script cheap kamagra viagra retail price cheap lovegra order viagra uk buy cialis in mexico viagra prescription price purchase cialis online without prescription online cialis prescription ranbaxy caverta buy viagra in hong kong sildenafil price cialis mastercard buy viagra in england viagra mail order canada cialis tablets for sale order cialis cialis soft tabs generic levitra india tadalafil prices cheap sildenafil citrate tablets cialis online prescriptions cialis 5 mg daily levitra prices prescriptions viagra viagra over the counter alternative cialis 20 mg tablets cialis generic india cialis prescribing cialis 20mg daily sildenafil 50 mg viagra drug prices tadalafil generic india cialis sale viagra prices buy viagra 50 mg levitra pharmacy buy viagra generic viagra prescription drug cialis daily cost vardenafil uk viagra soft tabs online buy viagra super active cialis 10mg price 25mg viagra silagra 100mg online viagra prescriptions cialis prescription cheap cialis india revatio 20 mg indian equivalent of viagra tadalafil india viagra capsules cheapest viagra buy cialis without prescription tadalafil overnight cheap tadalafil online purchase viagra online no prescription