How to install/enable intl and xsl extensions after installing PHP 7
When you deploy a stack using automation scripts like the one from lj2007331, convenience often comes at the cost of completeness. The specific script mentioned targets a php7/apache2.4/mysql5.6 combination on Ubuntu 14.04, which is a legacy environment where packages were often pre-compiled or manually curated to ensure binary compatibility. While this approach gets the server running quickly, it frequently leaves out non-critical extensions like intl and xsl. If you are deploying Magento2, these aren't optional luxuries; they are hard dependencies. The Intl extension handles timezone data and locale formatting, while XSL is required for transforming XML documents, a core feature of the Magento templating engine.
The primary challenge with Ubuntu 14.04 is that it reached end-of-life long before PHP 7 was widely supported in its official repositories. Consequently, standard apt-get install php7-intl php7-xsl commands will fail or pull from an outdated source that doesn't match your specific PHP binary version. You cannot simply drop a generic package into a system where the underlying libraries (like libicu for intl or libxslt for xsl) might be missing or mismatched.
To resolve this, you must ensure the correct development libraries are installed before compiling or enabling the extensions. For Ubuntu 14.04 running PHP 7, the most reliable path is using PPA repositories that provide backported PHP 7 packages compatible with the system's older glibc and OpenSSL versions. First, add a trusted PPA that supports PHP 7 on legacy systems, such as ondrej/php, which was widely used for this specific era of Linux distributions.
Run the following to update your package lists and install the necessary dependencies:
sudo apt-get update
sudo apt-get install php-pear libicu-dev libxml2-dev libxslt1-dev curl git unzip
Once the development headers are present, you need to enable the modules for your specific PHP version. Since the base installation script likely installed PHP 7 as a separate binary (e.g., php7.0), you must target that exact version string. Use the following commands to install the extensions:
sudo apt-get install php7.0-intl php7.0-xsl
After installation, the modules are typically loaded automatically if they exist in the conf.d directory, but you should verify their presence. Create a configuration file or edit your existing php.ini to ensure the extensions are explicitly enabled:
echo "extension=intl" | sudo tee /etc/php/7.0/mods-available/intl.ini
echo "extension=xsl" | sudo tee /etc/php/7.0/mods-available/xsl.ini
Restart your web server to apply changes:
sudo service apache2 restart
Finally, verify the installation using the PHP CLI:
php -m | grep intl
php -m | grep xsl
If the modules do not appear in the list, you may need to create a symlink for the configuration files from the mods-available directory to mods-enabled. This step is crucial on Debian-based systems where the package manager installs config files but doesn't automatically enable them.
A common pitfall in this environment is ignoring library version mismatches. Magento2 requires specific versions of these extensions that align with PHP 7's internal C API. Installing generic packages without checking the version number can lead to runtime fatal errors when Magento attempts to load the module. Always check the output of php -v and ensure your extension versions are compatible. If you encounter segmentation faults or "module not found" errors despite these steps, investigate whether libicu is installed; intl relies heavily on this library, and Ubuntu 14.04 defaults to an older version that might conflict with newer PHP builds.
If standard repository packages fail due to dependency hell inherent in EOL systems, consider compiling from source using PECL. This requires installing the PHP development package (php7.0-dev) and then running pecl install intl followed by pecl install xsl. However, given the constraints of Ubuntu 14.04, sticking to the curated PPA packages is usually safer and faster than attempting a manual compile, which risks breaking the Apache module loading order.