Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot download composer - 1and1 with ssh access to server

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() phpinfo()

php -v php -v

like image 224
Gravy Avatar asked Nov 01 '13 19:11

Gravy


People also ask

Do I need to install composer on server?

yes, but it's not necessary to download vendors with composer install . you can move composer binary file to Server and move your vendor too, then place vendor folder on your project and use composer dump-autoload .

How do I know if Composer is installed on my server?

You can check your installed composer version using a command composer -v at the current path. Such as: composer -v.


1 Answers

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.2
  • php5.5: Version 5.5
  • php6: Version 5.4

You have to invoke composer using php5.5 and it will just work.

like image 90
Gabriel G. Avatar answered Sep 18 '22 00:09

Gabriel G.