Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install Composer on a shared hosting?

I have these things:

  • the file http://api.odtu.lu/composer.phar
  • http://api.odtu.lu/phpinfo.php
  • ftp access
  • cPanel
  • Cron jobs on FreeBSD
  • PHP, Perl, CGI-BIN, Python, Curl.

How can I install Composer? (My aim is to install Restler)

Edit: I do not have SSH access.

like image 480
ilhan Avatar asked Jan 03 '14 00:01

ilhan


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 run composer on a server?

download composer. phar https://getcomposer.org/download/ - this is PHP Archive which can be extracted via Phar() and executed as regular library.


2 Answers

This tutorial worked for me, resolving my issues with /usr/local/bin permission issues and php-cli (which composer requires, and may aliased differently on shared hosting).

First run these commands to download and install composer:

cd ~ mkdir bin mkdir bin/composer curl -sS https://getcomposer.org/installer | php mv composer.phar bin/composer 

Determine the location of your php-cli (needed later on):

which php-cli 

(If the above fails, use which php)

It should return the path, such as /usr/bin/php-cli, /usr/php/54/usr/bin/php-cli, etc.

edit ~/.bashrc and make sure this line is at the top, adding it if it is not:

[ -z "$PS1" ] && return 

and then add this alias to the bottom (using the php-cli path that you determined earlier):

alias composer="/usr/bin/php-cli ~/bin/composer/composer.phar" 

Finish with these commands:

source ~/.bashrc composer --version 
like image 112
Johnathan Elmore Avatar answered Oct 19 '22 18:10

Johnathan Elmore


It depends on the host, but you probably simply can't (you can't on my shared host on Rackspace Cloud Sites - I asked them).

What you can do is set up an environment on your dev machine that roughly matches your shared host, and do all of your management through the command line locally. Then when everything is set (you've pulled in all the dependencies, updated, managed with git, etc.) you can "push" that to your shared host over (s)FTP.

like image 37
Kevin Newman Avatar answered Oct 19 '22 17:10

Kevin Newman