Reputation: 12445
I have SSH access to my 1and1 server. I am trying to download composer.
Following instructions from http://getcomposer.org/download/
Attempt 1:
user:~ > curl -sS https://getcomposer.org/installer | php
X-Powered-By: PHP/4.4.9
Content-type: text/html
<br />
<b>Parse error</b>: syntax error, unexpected '{' in <b>-</b> on line <b>316</b><br />
Attempt 2:
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
Error in argument 1, char 2: option not found r
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
Am I doing something obviously wrong?
I know that it is saying that I am running php 4.4.9, but if I run phpinfo(), it says PHP Version 5.4.21
is running. Any suggestions on what is going on here?
phpinfo()
php -v
Upvotes: 6
Views: 8525
Reputation: 741
Currently 1&1 offers a bunch of PHP versions under different aliases.
However the easiest way to set a default PHP version to use is from your 1&1 dashboard PHP settings and set it per domain individually. This is located under Hosting and then PHP settings. [1&1 PHP Settings (United States site)]
Note that 1and1 updates the PHP versions now quite regularly and also the CLI version may differ to the one user to render your site.
Original answer. It's been a long time, I recommend using the the latest 7.x.
There actually are 4 versions of php preinstalled on all the 1and1 linux shared hosting.
Command:
php
: Version 4.4 (The one you're actually using with composer.)php5
: Version 5.2php5.5
: Version 5.5php6
: Version 5.4You have to invoke composer using php5.5 and it will just work.
Upvotes: 15
Reputation: 3758
You should use the correct version of PHP curl -sS https://getcomposer.org/installer | php5.5
Upvotes: 5
Reputation: 486
The reason you are getting different php versions is because 1and1 has different php versions installed, for both client, and web.
So, if you change your settings (in the 1and1 control panel) so that you're using php5.4, when you run the phpinfo() command, it will reflect that.
However, the command line version will still reflect the default php version for 1and1, which is 4.4.9 (as of today).
So, force the php5 version for your composer install, but also change the global version to 5.4, and you'll be fine.
Here's what happened when I did it.
~/demo > curl -sS https://getcomposer.org/installer | php6
X-Powered-By: PHP/5.4.28
Content-type: text/html
#!/usr/bin/env php
All settings correct for using Composer
Downloading...
Composer successfully installed to: /homepages/19/[my1and1info]/htdocs/demo/composer.phar
Use it: php composer.phar
(uiserver):[my1and1info]:~/demo>
Upvotes: 1
Reputation: 39
On 1and1, the PHP version for your virtual server seems to be frozen until you update it. There's a "global PHP version" page on the dashboard. I just found it and advanced mine from 4-something to 5.5.
Upvotes: 1
Reputation: 70863
If that server is your production server, you probably shouldn't use it to complete your application, but use your local development machine to download everything, and then upload the whole directory.
From what I see on your shell, you are using a PHP version that is ancient. It is the PHP 4.4 version used as command line, and this clearly does not work with composer. Either you search for the 5.3 version of PHP on that machine (I wonder if it might be called php53
or something), and then hope all necessary extensions are installed, most likely including the "GIT" command line tool, probably also "SVN", or that search will not really help you, because you still would lack the necessary tools for a successful Composer experience.
Composer is a development dependency manager. It probably is not intended to maintain a production server's code base.
Upvotes: 0