Skip to content

Instantly share code, notes, and snippets.

@edsqjr
Last active April 29, 2024 21:04
Show Gist options
  • Save edsqjr/c3d2669d7ed1e594a6e22565a9c3b8e1 to your computer and use it in GitHub Desktop.
Save edsqjr/c3d2669d7ed1e594a6e22565a9c3b8e1 to your computer and use it in GitHub Desktop.
Install php + composer on Ubuntu 22.04 LTS
# resumed from references:
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos
https://stackoverflow.com/questions/19335305/composer-install-error-requires-ext-curl-when-its-actually-enabled
# install php 8.1 from package
sudo apt-get install php8.1
# install composer from script
wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet
# set "composer" as a command shell
sudo mv composer.phar /usr/local/bin/composer
# check needed dependencies
composer diagnose
# if curl unavailable...
# install curl
sudo apt-get install curl
# install curl extension for php
sudo apt-get install php8.1-curl
# if zip, unzip, 7-zip unavailable or disabled
# install via package
sudo apt-get install unzip 7zip
# enable modules in php.ini
# first, locate the correct php.ini file...
php -i | grep "php.ini"
# suppose it's '/etc/php/8.1/cli/php.ini'.. edit the file
sudo vim /etc/php/8.1/cli/php.ini
# in php.ini file, locate line for curl extension and remove comment
...
extension=curl
...
# confirm changes
composer diagnose
note: it's assumed you have git installed in your system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment