Install PHP Composer via Jelastic SSH Gateway
The instruction below enables to install PHP Composer - a popular dependency management tool - via Jelastic SSH Gateway. It involves a few adjustments that allow to execute Composer from any working directory on a server without having to write out its full path.
Once you’ve established SSH connection to your Apache PHP or NGINX PHP server (Apache 2.4 in our example), you can easily integrate Composer into your project. So, let’s see how to download and run this tool.
The steps below show how to install Composer and perform its configuration, that will enable us to execute it from any working directory throughout a server.
1. Run the Composer installer from inside your server working directory to download the appropriate composer.phar archive:
curl -sS https://getcomposer.org/installer | php
2. Rename the composer.phar file to just “composer” and move it to the private bin directory with the below commands:
mkdir ~/bin mv ~/composer.phar ~/bin/composer
3. Now, let’s add Composer to the server PATH variable in order to be able to further execute it from any server directory. In such a way, you won’t have to write out the full path (i.e. /var/www/bin/composer) for calling this dependencies manager when necessary.
For that, run one of the following commands depending on used application server:
- for Apache PHP:
export PATH=$PATH:/var/www/bin echo 'export PATH=$PATH:/var/www/bin' << ~/.bashrc
- for NGINX PHP:
export PATH=$PATH:/var/lib/nginx/bin echo 'export PATH=$PATH:/var/lib/nginx/bin' << ~/.bashrc
That’s it! Composer is added to your PATH variable now.
4. Everything is already set up! You can run the following command in order to ensure that PHP Composer works as intended:
Great! Now you can freely use Composer on your Apache or NGINX server and manage dependencies within your PHP projects.