Install PHP 7.4 on Alpine Linux

Mar 07, 2023 · 1 min read · Post a comment

Trying to set up PHP 7.4 on Alpine Linux can lead to the following error:

ERROR: unable to select packages:
  php7 (no such package):
    required by: world[php7]

This might get things complicated. So, after digging for a while I found some workaround that will share with you. Let’s install PHP 7.4 on Alpine Linux.


  • Alpine Linux
  • sudo privileges

Install PHP 7.4 on Alpine Linux

Step 1. Add the following repository.

echo "" >> /etc/apk/repositories

Step 2. Update the packages.

apk update && apk upgrade

Step 3. Install php 7.4.

apk add php7

Step 4. Verify the installation.

php7 -v


PHP 7.4.33 (cli) (built: Feb 15 2023 18:20:29) ( NTS )
Copyright (c) The PHP Group


Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.