Skip to content

How to install all required PHP extensions for Laravel?

Laravel requires the following PHP extensions:

  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • XML PHP Extension
  • BCMath PHP Extension
  • JSON PHP Extension
  • Zip PHP Extension
  • Curl PHP Extension
  • GD PHP Extension

Note: Database drivers (e.g., pdo_mysql) are optional and depend on your project's configuration.

To install these extensions, you will need to have root access to your server. If you are using a shared hosting environment, you may not have root access and will need to contact your hosting provider to have these extensions installed for you.

If you have root access to your server, you can install these extensions using the following steps:

  1. Log in to your server using SSH.
  2. Update your package manager's package list by running the following command:
bash
sudo apt-get update
  1. Install the required PHP extensions by running the following command:
bash
sudo apt-get install php8.2-openssl php8.2-pdo php8.2-mbstring php8.2-xml php8.2-bcmath php8.2-json php8.2-zip php8.2-curl php8.2-gd

Replace 8.2 with your installed PHP version.

  1. Restart your web server to apply the changes. If you are using Apache, you can do this by running the following command:
bash
sudo systemctl restart apache2

If you are using a different web server, such as Nginx, you will need to use the appropriate command for that server.

  1. Verify the installation by running php -m and confirming that the extensions are listed.

That's it! You should now have all of the required PHP extensions installed and configured for use with Laravel.

Dual-run preview — compare with live Symfony routes.