Skip to content

Instantly share code, notes, and snippets.

@davidalger
Created December 2, 2019 17:50
Show Gist options
  • Save davidalger/c19a53ed293291ec2e93b5227f9e0a2d to your computer and use it in GitHub Desktop.
Save davidalger/c19a53ed293291ec2e93b5227f9e0a2d to your computer and use it in GitHub Desktop.
Install php-sodium on EL 8

There is currently no pre-built package available for the php sodium ext currently. And due to the changes made to the EL 8 packaging system, IUS no longer plans to maintain any packages for EL 8 (alternate versions of packages such as PHP should eventually become available via additional module streams published in the AppStream repo) so it's not available via IUS either beyond EL 7.

Magento will fallback on sha256 for password hashes when sodium is unavailable:

public function getLatestHashVersion(): int
{
    if (extension_loaded('sodium') && defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13')) {
        return self::HASH_VERSION_ARGON2ID13;
    }
    return self::HASH_VERSION_SHA256;
}

This causes exceptions on admin login if you load a database with Argon2ID13 hashes into a system missing the sodium extension. I'd venture to guess this may cause issues with encrypted config values, although I haven't dug that far into it yet.

yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
&& yum install -y php-cli libsodium \
&& yum install -y php-pear php-devel libsodium-devel make \
&& pecl channel-update pecl.php.net \
&& pecl install libsodium \
&& yum remove -y php-pear php-devel libsodium-devel make \
&& echo 'extension=sodium.so' > /etc/php.d/20-sodium.ini \
&& php -i | grep sodium
@Kas-tle
Copy link

Kas-tle commented Sep 3, 2023

Thanks! FYI if using PHP 8.1 it will say the version is incompatible but you can override with:

pecl install -f libsodium 

and at least on the current PHP 8.1 there should be no issues.

@faceandtable
Copy link

Thank you. It worked.

@k-barber
Copy link

👍

@luisdardon
Copy link

Thanks, works for me on Linux Amazon 2023.

@haidang88
Copy link

Thanks, worked perfectly on OL 8

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