This shows you the differences between two versions of the page.
— |
kb:php:composer:00002 [2019/07/01 23:37] (current) created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== How To Install and Use PHP Composer on BlueOnyx 5209R ====== | ||
+ | Ensure that you have met the following prerequisites before continuing with this tutorial: | ||
+ | |||
+ | * Logged in as a user with sudo privileges | ||
+ | * Have PHP 7 installed on your CentOS 7 system. | ||
+ | |||
+ | ===== Installing Composer on BlueOnyx ===== | ||
+ | |||
+ | The following steps describe how to install Composer on a BlueOnyx 5209R system. | ||
+ | |||
+ | ==== 1. Pre-requisites ==== | ||
+ | |||
+ | First install the PHP CLI (command line interface) package and all other dependencies with: | ||
+ | |||
+ | sudo yum install php-cli php-zip wget unzip | ||
+ | |||
+ | ==== 2. Get the installer ==== | ||
+ | |||
+ | Once PHP CLI is installed, download the Composer installer script with: | ||
+ | |||
+ | sudo php -d allow_url_fopen=1 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
+ | |||
+ | ==== 3. Verify ==== | ||
+ | |||
+ | To verify the data integrity of the script compare the script SHA-384 hash with the latest installer hash found on the Composer Public Keys / Signatures page. | ||
+ | |||
+ | The following wget command will download the expected signature of the latest Composer installer from the Composer’s Github page and store it in a variable named HASH: | ||
+ | |||
+ | HASH="$(wget -q -O - https://composer.github.io/installer.sig)" | ||
+ | |||
+ | To verify that the installation script is not corrupted run the following command: | ||
+ | |||
+ | php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | ||
+ | |||
+ | If the hashes match, the following message will be shown: | ||
+ | Installer verified | ||
+ | |||
+ | |||
+ | If the hashes don’t match you will see Installer corrupt. In this case, you need to redownload the Composer installation script and double check the value of the $HASH variable with echo $HASH. Once the installer is verified, you can continue with the next step. | ||
+ | |||
+ | |||
+ | ==== 4. Install ==== | ||
+ | |||
+ | Run the following command to install Composer in the /usr/local/bin directory: | ||
+ | sudo php -d open_basedir= -d allow_url_fopen=1 composer-setup.php --install-dir=/usr/local/bin --filename=composer | ||
+ | |||
+ | ==== 5. Verify ==== | ||
+ | |||
+ | The last step is to verify the installation: | ||
+ | |||
+ | php -d open_basedir= /usr/local/bin/composer |