How to install all required PHP extensions for Laravel?
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: A Comprehensive Guide to Installing All Required PHP Extensions for Laravel on Ubuntu 16.04 (with Terminal and GUI Options)
Introduction: Ensuring that your Laravel application efficiently runs on the server is crucial. One of the most vital aspects is installing all necessary PHP extensions to enable your web app's smooth functioning. In this blog post, we will walk you through the process of enabling essential PHP extensions in Ubuntu 16.04 using both terminal and GUI methods, thus providing a complete solution for optimizing Laravel performance.
Prerequisites: You must have installed PHP 7.1 and MariaDB on your Ubuntu system before proceeding with the following steps. The required PHP extensions are as follows:
1. OpenSSL PHP Extension - Provides secure communication over networks using SSL/TLS encryption protocols.
2. PDO PHP Extension - Facilitates data access to various database types from within PHP scripts.
3. Mbstring PHP Extension - Handles multibyte encoded text strings, making it easier for internationalization and localization.
4. Tokenizer PHP Extension - Optimizes the execution time of code that involves lots of iterations by compiling it into opcodes.
5. XML PHP Extension - Parses and manipulates XML documents with ease using standardized DOM and SimpleXML APIs.
Installation Steps (Terminal):
Enabling extensions in terminal is more straightforward compared to the GUI method, as we can explicitly provide the required commands. Here are the steps for each extension:
1. OpenSSL PHP Extension:
a. To ensure the OpenSSL PHP Extension is installed on your system, run this command:
`sudo apt-get install php7.1-openssl`
2. PDO PHP Extension:
a. The following command will add all required libraries and install the PDO PHP Extension:
`sudo apt-get install php7.1-pdo php7.1-pdo_mysql`
3. Mbstring PHP Extension:
a. To enable multibyte support, run this command:
`sudo apt-install php7.1-mbstring`
4. Tokenizer PHP Extension:
a. Install the tokenizer module using:
`sudo apt install php7.1-tokenizer`
5. XML PHP Extension:
a. To parse and modify XML documents, run this command:
`sudo apt-get install php7.1-xml`
Installation Steps (GUI):
Although GUI installation seems simpler at first glance, it might be less efficient compared to terminal. Still, you can follow these steps for those who prefer this method:
1. Open the Synaptic Package Manager or Software Center depending on your Ubuntu version.
2. Search for "php7.1" and install all available packages that contain PHP 7.1. These will include the required extensions mentioned above along with other dependencies. Note that you might need to accept APT to resolve dependencies during installation.
3. Once all packages are installed, the necessary PHP extensions should be available on your system.
Testing and Conclusion:
After installing these extensions, ensure you have restarted Apache or whatever server software you're using for serving your Laravel application. To test your application code, create a simple Laravel application, then run "php artisan serve" to start the local development server. Visit the website URL in your browser and verify that all functionalities work as expected.
In conclusion, installing PHP extensions is integral to ensuring your Laravel app runs optimally on Ubuntu 16.04. Both terminal and GUI options have been discussed for ease of understanding. However, we highly recommend using the terminal method due to its efficiency and precise nature in terms of installation and troubleshooting.
As always, visit https://laravelcompany.com/blogs to learn more about Laravel development best practices and solutions.