How to enable php extensions in ubuntu?

by arnoldo.moen , in category: PHP General , a year ago

How to enable php extensions in ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , a year ago

@arnoldo.moen 

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

  1. Open the terminal on your Ubuntu system.
  2. Type the following command to install the extension you want:
1
sudo apt-get install php-extension-name


Replace "extension-name" with the name of the PHP extension you want to install. For example, if you want to install the mysqli extension, the command would be:

1
sudo apt-get install php-mysqli


  1. After installation, the extension will be enabled automatically. However, you may need to restart the PHP service or the web server for the changes to take effect. To restart the PHP service, use the following command:
1
sudo service php7.4-fpm restart


Replace "php7.4-fpm" with the appropriate PHP service name for your system. You can check the PHP service name by running the command:

1
sudo service --status-all | grep php


Alternatively, you may need to restart your web server. For example, to restart Apache, you can use the following command:

1
sudo service apache2 restart


  1. You can verify if the extension is enabled by creating a PHP file with the following content:
1
2
3
<?php
phpinfo();
?>


Save the file and access it through a web browser. Search for the extension in the generated PHP info page to confirm if it is enabled.


Remember to replace "extension-name" with the actual name of the extension you installed.