Website Vidya
DeploymentStep-by-Step Guide

How to Install PHP Intl Extension: 4 Easy Steps

PHP is one of the most widely-used server-side scripting languages for web development. It powers millions of websites worldwide due to its simplicity and flexibility. However, when developing multilingual websites or applications that need...

RR
Website Vidya TeamLead Systems Educator
Published:
7 min read
How to Install PHP Intl Extension: 4 Easy Steps
AI Executive SummaryCORE CIS AI

7 min read

PHP is one of the most widely-used server-side scripting languages for web development. It powers millions of websites worldwide due to its simplicity and flexibility. However, when developing multilingual websites or applications that need...

Key Highlights
  • Why Do You Need PHP Sodium?
  • How to Install PHP Sodium Extension on Ubuntu
  • How to Install PHP Sodium Extension on CentOS
Grounded in full engineering runbookCORE CIS Ai Engine

The PHP Sodium extension is a modern cryptography library designed to make encryption easier and more secure. If you’re developing applications that require cryptographic operations, learning how to install PHP Sodium extension is essential. In this guide, we will walk you through the steps to install the PHP Sodium extension on Ubuntu, CentOS, and other Linux distributions. Let’s dive in!

Why Do You Need PHP Sodium?

PHP Sodium provides advanced cryptographic features such as encryption, decryption, password hashing, and more. It is a highly reliable and efficient library integrated into PHP since version 7.2. By ensuring that the PHP Sodium extension is installed, you can secure your applications while leveraging its extensive cryptographic capabilities.

This extension simplifies the implementation of cryptographic functions, reducing the risk of errors that can compromise security. Moreover, its seamless integration into PHP means developers can access state-of-the-art encryption tools with minimal configuration.


How to Install PHP Sodium Extension on Ubuntu

Ubuntu is one of the most popular Linux distributions, and installing the PHP Sodium extension here is straightforward. Follow these steps to get started:

Step 1: Update Your Package List

Open your terminal and update the package list to ensure you’re downloading the latest versions of the required packages:

sudo apt update

This step ensures your system has access to the most up-to-date software repositories, minimizing compatibility issues.

Step 2: Install PHP and Required Extensions

Ensure you have PHP installed. If not, install it along with the necessary dependencies:

sudo apt install php php-cli php-dev -y

These packages include the core PHP interpreter, command-line tools, and development libraries needed for extension compilation.

Step 3: Install the Sodium Extension

For PHP 7.2 and above, the Sodium extension is bundled and enabled by default. However, if it is missing, you can manually install it:

sudo apt install php-sodium -y

This command retrieves the Sodium extension from the official Ubuntu repositories and integrates it with your PHP installation.

Step 4: Verify the Installation

After installation, confirm that the Sodium extension is enabled:

php -m | grep sodium

If the output shows “sodium,” the installation was successful. This step ensures your PHP environment is correctly configured.


How to Install PHP Sodium Extension on CentOS

CentOS is widely used in server environments. Follow these steps to install the PHP Sodium extension:

Step 1: Update the System

Update your system to ensure compatibility:

sudo yum update -y

Keeping your system updated reduces potential issues caused by outdated dependencies.

Step 2: Install PHP and Developer Tools

Install PHP and development tools required for building extensions:

sudo yum install php php-cli php-devel gcc make -y

These tools allow you to compile and install custom PHP extensions if needed.

Step 3: Install Sodium Library

Install the libsodium library, which is required for the PHP Sodium extension:

sudo yum install libsodium libsodium-devel -y

This step ensures that the underlying cryptographic library is available for PHP to interface with.

Step 4: Install the Sodium Extension

For CentOS, you may need to use pecl to install the extension:

sudo pecl install libsodium

The pecl command downloads and compiles the Sodium extension, ensuring compatibility with your PHP version.

Step 5: Enable the Extension

Add the following line to your PHP configuration file (usually php.ini):

extension=sodium.so

This line tells PHP to load the Sodium extension during startup.

Step 6: Verify the Installation

Restart your web server and confirm the installation:

php -m | grep sodium

If “sodium” appears in the output, the installation is complete. Restarting ensures all changes take effect.


Installing PHP Sodium on Other Linux Variants

For other Linux distributions such as Fedora, Debian, or Arch Linux, the steps are similar. Here is a general guide:

Step 1: Update Your System

Always begin by updating your system:

sudo dnf update    # Fedora
sudo apt update    # Debian
sudo pacman -Syu   # Arch Linux

This step ensures you’re working with the latest package versions and dependencies.

Step 2: Install PHP and Dependencies

Ensure PHP and the required development libraries are installed. For example:

sudo dnf install php php-cli php-devel -y    # Fedora
sudo apt install php php-cli php-dev -y      # Debian
sudo pacman -S php php-cli php-dev           # Arch Linux

These commands install the PHP interpreter and necessary tools for building extensions.

Step 3: Install the Sodium Extension

On most distributions, the Sodium extension can be installed via the default package manager or pecl:

sudo pecl install libsodium

The pecl utility is a versatile tool for adding PHP extensions that may not be included in standard repositories.

Step 4: Enable and Verify the Extension

Add extension=sodium.so to your php.ini file and verify the installation using:

php -m | grep sodium

Verifying ensures the extension is active and properly integrated with your PHP setup.


Common Issues and Troubleshooting

  • PHP Version Compatibility: Ensure your PHP version is 7.2 or higher. If not, consider upgrading your PHP installation. Older versions of PHP do not include native support for Sodium.
  • Missing Development Tools: If you encounter errors during installation, ensure development tools like gcc and make are installed. These tools are critical for compiling extensions from source.
  • Extension Not Found: Double-check your PHP configuration files and restart the web server after enabling the extension. Sometimes, misconfigurations or typos in php.ini can prevent extensions from loading.
  • Library Conflicts: Ensure there are no conflicting versions of the libsodium library on your system. Use your package manager to check for duplicate installations.

Conclusion

Installing the PHP Sodium extension on Linux distributions like Ubuntu, CentOS, and others is a straightforward process. By following this guide on how to install PHP Sodium extension, you can enable powerful cryptographic capabilities in your PHP applications. Whether you’re enhancing data encryption or implementing secure password hashing, Sodium is a tool you can trust.

Take the time to verify your installation and troubleshoot any issues to ensure your PHP environment is secure and optimized. With the PHP Sodium extension, you’re equipped to build applications that meet modern security standards. Start today and give your projects the robust protection they deserve!


Written by

Website Vidya Team

Technology educator and researcher at Website Vidya.

Discussion

0
Share your thoughts, ask a question, or suggest a tip...
Write →

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Deployment•

How to Install PDO Extension in PHP

PHP Data Objects (PDO) is one of the most important extensions in PHP for working with databases in a secure, consistent, and modern way. If you are building dynamic websites, APIs, CMS platforms, or enterprise applications, PDO is not opti...

RR
Rajesh Rai
Read More
Deployment•

How to Install PHPMyAdmin on Ubuntu: 4 Simple Steps

If you’re working with MySQL or MariaDB on Ubuntu, managing databases purely from the command line can quickly feel overwhelming. That’s where phpMyAdmin comes in. PHPMyAdmin is a web-based application that provides a Graphical User Interfa...

RR
Rajesh Rai
Read More
Deployment•

25 Best Linux Commands Every Sysadmin Should Know

If you’ve spent any time managing Linux servers, you already know this truth: the command line is not optional. It’s where real troubleshooting happens, where performance issues are understood, and where outages are prevented before users e...

RR
Rajesh Rai
Read More
Deployment•

How to Fix Snapd Consuming High CPU / RAM on Linux

If you’ve ever opened your system monitor and noticed snapd quietly eating up your CPU or RAM, you’re not alone. Many Linux users—especially on Ubuntu and Ubuntu-based distributions—eventually run into this issue and wonder what’s going on ...

RR
Rajesh Rai
Read More
Deployment•

How to Fix Broken Packages in Ubuntu: 7 Simple Ways

If you’ve been using Ubuntu for a while, chances are you’ve run into package-related issues at least once. A failed update, an interrupted installation, or conflicting dependencies can easily leave your system in a messy state. When that ha...

RR
Rajesh Rai
Read More