Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomaskanzig/7adfbc8a84d2f80e9c4671f51a023308 to your computer and use it in GitHub Desktop.
Save thomaskanzig/7adfbc8a84d2f80e9c4671f51a023308 to your computer and use it in GitHub Desktop.
Install PHP Composer on Rocky Linux 8 Globally

Install PHP Composer on Rocky Linux 8 Globally

Download PHP Composer Installer Script:

Run the command below to download PHP composer installer script:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Verify the integrity of the installer.

To confirm that you are installing the actual composer, you need to verify the integrity of the installer script downloaded above. This can be done by downloading the hash and comparing and validating as follows:

php -r "if (hash_file('sha384', 'composer-setup.php') === '$(wget -qO - https://composer.github.io/installer.sig)') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

You should see an output like:

Installer verified

Install PHP Composer on Rocky Linux 8 Globally

php composer-setup.php --install-dir=/usr/bin --filename=composer

If you see this error:

All settings correct for using Composer
The installation directory "/usr/bin" is not writable

Then try to execute again with sudo:

sudo php composer-setup.php --install-dir=/usr/bin --filename=composer

Remove the installer

Remove the installer once Composer is installed:

php -r "unlink('composer-setup.php');"

Verify Composer Installation by running the command.

composer -v

You will see something like this:

image

Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment