I had a little trouble installing and using drush on 1and1, and I wanted to post back the solution that worked for me. It's taken right from drush installation notes, but like all things opensource, it's good to spread the SEO to specifically 1&1 hosting which defaults php interpreter to php4. Drush needs php5.

Per the instructions, just force php5 by creating a .profile (you probably don't have one yet) in your home directory that contains:

alias drush='/usr/local/bin/php5 ~/drush/drush.php'
export COLUMNS

In this case, my drush is installed under /*/*/*/*/htdocs/[drush]

Just like the README.txt says, you'll need to log back in (via ssh) to reread .profile and let this alias become active.

Hope this helps!
-Bronius

Comments

WillHall’s picture

holy... - they are still defaulting to php4? Wow... Awesomeness!

katherined’s picture

Remember to make sure to use the full absolute path, which is some long string of stuff if you are using 1and1 shared hosting. If you need to figure out what that is, google "find my absolute path" and you're sure to find some code that might help.

Also, you'll want to add the line 'export COLUMS' after the alias. Per the drush readme:

NOTE FOR ADVANCED USERS
- If you want to run drush with a specific version of php, rather than the
one found by the drush command, you can instead create an alias that
executes the drush.php file directly:
$ alias drush='/path/to/php/php5 /path/to/drush/drush.php'
If you do this, to allow Drush to detect the number of available columns,
you need to add the line 'export COLUMNS' to the .profile file in your
home folder.

texas-bronius’s picture

Ok good call (and I've added it to my own .profile).
For the record, I am not on 1&1-- it's a client's host. I just felt unclean without clearing that up.

--
http://drupaltees.com
80s themed Drupal T-Shirts

greg.1.anderson’s picture

Note that when the "drush" script invokes drush.php, it also includes the --php option to specify where your php is located. This is really important if you're going to use any of the drush features that cause drush to call itself (e.g. pm-update).

alias drush='/usr/local/bin/php5 ~/drush/drush.php --php=/usr/local/bin/php5'

Yeah, this should be in the installation notes...

markgukov’s picture

Creating the alias is all I needed to do, ie no need for the profile file.

Jon_gw’s picture

Thanks for you input. I am getting closer but not quite there. I put the alias drush='/usr/local/bin/php5 ~/drush/drush.php' and export COLUMNS in a .profile as you suggested and I no longer get the php too old message. What I now see is;
Status: 404 Not Found
X-Powered-By: PHP/5.2.13
Content-type: text/html

No input file specified.

I even tried putting the path from pwd inplace of the "~" and received the same results.
I even put drush in ~/drush/ to match your example. The one addition thing I tried was to add execute permission to drush/drush and all *.php I could find (six of them).

Thanks,
Jon

texas-bronius’s picture

Fwiw, I didn't have to set execution permissions on this 1and1.com shared host account.

Note that I derived ~/drush by downloading the drush tgz and extracting in the htdocs (or ~) folder directly. I think you're on the right path but have maybe extracted elsewhere. I put my installation here because it was outside the site root, and I didn't have write access to anything just above that folder (to my knowledge).

--
http://drupaltees.com
80s themed Drupal T-Shirts

Jon_gw’s picture

Thanks all for your input. What finally worked for me was to put the crowning touches posted by greg.1.anderson (--php=/usr/local/bin/php5'). I had been testing my effort by just typing drush or drush help. It is curious why your install worked without it but not curious enough for me to spin my wheels figuring it out. Beside, with my bash and drupal knowledge, I don't get much traction.

Thanks again for your help.
Jon

texas-bronius’s picture

Ah! Maybe it's due to my remnant earlier attempt wherein I modified ./drush/drush toward the bottom:

exec php5 $SCRIPT_PATH --php=`which php5` "$@"

It used to be:

exec php $SCRIPT_PATH --php=`which php` "$@"

HAhahaha (no seriously)

--
http://drupaltees.com
80s themed Drupal T-Shirts

texas-bronius’s picture

Fyi, I've updated this 1and1 client's .profile alias to:
alias drush='/usr/local/bin/php5 -q ~/drush/drush.php'
in order to suppress the

X-Powered-By: PHP/5.2.14
Content-type: text/html

per #923654: drush outputs http headers when used from the command line

--
http://drupaltees.com
80s themed Drupal T-Shirts

baisong’s picture

On 1and1.com server, I've done everything you did in the .profile file, and logged out and back in. I also made sure the drush file is executable, but I still get

$~ drush
No input file specified.

here's my .profile file (actual pathname redacted):

alias drush='/usr/local/bin/php5 -q -d memory_limit=80M /*/*/*/*/htdocs/bin/drush/drush.php --php=/usr/local/bin/php5 -q -d'
export COLUMNS
baisong’s picture

Interesting... the 'no input file specified' error might mean that

/*/*/*/*/htdocs/bin/drush/drush.php

should be

/*/*/*/*/htdocs/bin/drush/drush

...but when I change that, it just outputs the content of the drush script...

baisong’s picture

Somehow my drush.php (and a number of other files) were not actually copied over onto my server. Once the drush.php file was there, it all worked :)

Hooray for descriptive error messages!

greg.1.anderson’s picture

Note that you probably also want extra quoting around your --php arg.

alias drush='/usr/local/bin/php5 -q -d memory_limit=80M /*/*/*/*/htdocs/bin/drush/drush.php --php="/usr/local/bin/php5 -q -d"'

Didn't try that, but it looks right.

If you upgrade to drush-5.x, then you can just set the DRUSH_PHP environment variable to point at the php you'd like to use. Don't put any php commandline options in DRUSH_PHP -- it should contain only the full path to php. Put php options into $HOME/.drush/drush.ini. See drush topic docs-ini-files for more information.

nathan.pride’s picture

While all the above is very helpful for getting drush to work when you have the console open on your 1and1 account, I had some issues when running drush remotely, it was ignoring .profile so I managed to add a bit to my aliases.drush.php file, the key line here is %drush-script I hope this of some help.

$aliases['mysite.live'] = array(
    'remote-host' => 'mysite.com',
    'remote-user' => 'myuser',
    'remote-root' => '/.../.../.../.../htdocs/mysite',
    'uri' => 'www.mysite.com',
    'root' => '/.../.../.../.../htdocs/mysite',
    'ssh-options' => '-i ~/.ssh/mysite.private',
    'path-aliases' => array(
        '%drush-script' => '/usr/local/bin/php5 /<PATH TO>/htdocs/drush/drush.php --php=/usr/local/bin/php5',
    ), 
); 
1066’s picture

Spoke with 1&1 for awhile. They stated that Drush cannot be used with 1&1 shared hosting.
You need a dedicated server package.

netcastle’s picture

I would like to reply that while 1and1 may not officially support the use of drush on their shared severs, it does work with the above method. At least it works as of this posting.

Pink96’s picture

aside from getting the "permission denied" message...

I get this error

X-Powered-By: PHP/4.4.9
Content-type: text/html

Parse error: syntax error, unexpected '{' in /*/*/*/*/*/drush/includes/environment.inc on line 518

I have the Business package using Linux and PHP5 is installed

my head is about to burst... lol

Anonymous’s picture

Drush "kind of" works for me (Developer package and 1and1) but I think I figured out why it does not work correctly.

I don't believe that 1and1 has the command line php installed. I have php5 on my Ubuntu workstation and I never see these headers when executing php from the command line:

X-Powered-By: PHP/5.2.17
Content-type: test/html

Also the output never has tags like or
in it. That's a sign (to me) that it's not the command line PHP.

Shopping over at Linode.com now.

Good luck.

Eric Lucas

hawkeye126’s picture

I get this error, pretty much the same as the last poster but my perms are not denied.

X-Powered-By: PHP/4.4.9
Content-type: text/html

Parse error: syntax error, unexpected '{' in /*/*/*/*/*/drush/includes/environment.inc on line 518

I have the Business package using Linux and PHP5 is installed

Help would be awesome, I'd rather update with drush than otherwise. Thanks!

ysam’s picture

mine is a business account (1and1 hosting), and after several attempts I just got mine working.

I follow this intruction: http://networkedblogs.com/E7og2
========
Then you will have to add this to the top of the drush/drush.php file after the first < ?php:
if (!defined('STDIN'))
{
define('STDIN', fopen('php://stdin', 'r'));
}
if (!defined('STDOUT'))
{
define('STDOUT', fopen('php://stdout', 'w'));
}
if (!defined('STDERR'))
{
define('STDERR', fopen('php://stderr', 'w'));
}
=====
and here is my .profile content:

alias drush='/usr/local/bin/php5 -q /kunden/homepages/*/*/htdocs/drush/drush.php --php=/usr/local/bin/php5'
export COLUMNS

Hope this help

PedroKTFC’s picture

On 1and1 I couldn't enable a module that wanted PHP version 5.3 at least. By trial and a lot of error, I found that you need to use an alias for php6 on 1and1. (Try 'which php5' etc.)

The following line in my .bash_profile gives me PHP 5.4 for Drush (notice the slightly different path):

alias drush='/usr/bin/php6 -q /kunden/homepages/*/*/htdocs/drush/drush.php --php=/usr/bin/php6'

jalake’s picture

Thanks, PedroKTFC using PHP6 for drush did the trick for me. ... Find it odd that 1and1 global php for my domain is set to 5.4 but it reports as 5.2.17 on 'php --version'

stevenx’s picture

thanks, this made my day! trial and error

stevenx’s picture

I also made a blogpost about it...

updated it today...

https://stevenschulz.net/blog/drush-auf-1und1-server-installieren-mit-composer

Vaene’s picture

Thanks for the above post, modded it a bit for my situation and it works! Only difference is in ~/.bashrc I have

alias drush='/usr/bin/php6 -q ~/drush/drush.php --php=/usr/bin/php6'
export COLUMNS

Thanks again!

greg.1.anderson’s picture

All of the advice on this page for aliasing drush to call php directly is a few years old. Nowadays, you are better off setting the DRUSH_PHP environment variable and calling the 'drush' script directly.