Here is how to install Composer on a Synology, required among other to install various php applications available on GitHub, like the “Simple SPK Server“.
Click to Read More
To install Composer, the following extensions must be loaded into php: curl, openssl and phar.
Connect into your DSM, open the Web Station via the Main Menu and enter the PHP Settings. There, select first the “PHP version” = “PHP 5.6”, tick the Extensions: curl, openssl and phar, and click Apply. Next, do the same for the “PHP version” = “PHP 7.0”.
Configuring extensions for php as illustrated above is only valid for the WebStation.
Open a SSH Console via Putty, log in as an administrator and enter next the root mode.
To load extensions into php, their respective php.ini file must be updated manually (Ex.: Edit them from a SSH console using VI). Path to php.ini are:
- php70: /usr/local/etc/php50/php.ini
- php73: /usr/local/etc/php73/cli/php.ini
In php ini, under the section [PHP] add the following lines
extension = phar.so extension = openssl.so extension = zip.so
To install Composer, use following commands:
cd /usr/local/bin
curl -s http://getcomposer.org/installer | php70
This should display the following message:
All settings correct for using Composer
Downloading…
Composer (version 1.3.1) successfully installed to: /usr/local/bin/composer.phar
Use it: php composer.phar
On Synology, php is not the command to use to run Composer. Instead, one should use php56 or php70. Ex.:
php70 composer.phar –version
To make use of it more easily, you can create a script. Use the command vi
vi composer
Enter the modification mode by typing the letter “i”.
Type the following text:
#!/bin/bash
php56 /usr/local/bin/composer.phar $*
Press ‘Esc’ to quit the modification mode.
To write the changes and quit vi, type next “:wq” (without the quotes).
Make the script executable with the following command:
chmod +X composer
Try now:
composer –version
Et voilà.
NB.:
- The following command can also be used to install ‘composer’ with the ‘php’ command: curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer
- The following command can be used to update ‘composer’ : sudo composer self-update
Leave a Reply