How to enable php extensions in ubuntu?


by larissa , in category: PHP General , 4 months ago

How to enable php extensions in ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by haylee.mertz , 4 months ago


To enable PHP extensions in Ubuntu, you can follow these steps:

  1. Locate the php.ini file: The php.ini file is usually located in the /etc/php/{PHP_VERSION}/apache2 directory. Replace {PHP_VERSION} with your PHP version (e.g. 7.4).
  2. Edit the php.ini file: Open the php.ini file in a text editor such as nano or vi. Look for the line that starts with "extension=". Uncomment this line by removing the semicolon (;) and add the name of the extension you want to enable (e.g. for the GD extension).
  3. Save the changes: Save the changes to the php.ini file and exit the text editor.
  4. Restart the Apache web server: After enabling the extension in the php.ini file, you will need to restart the Apache web server for the changes to take effect. You can do this by running the following command:
sudo systemctl restart apache2

  1. Verify the extension is enabled: You can verify that the extension is enabled by creating a phpinfo.php file in your web server's document root directory (e.g. /var/www/html) with the following content:
<?php phpinfo(); ?>

Access this file through a web browser and search for the extension you enabled to confirm that it is now enabled in your PHP installation.

That's it! You have successfully enabled a PHP extension in Ubuntu.