This brief guide outlines the process of installing the PHP JSON extension on Ubuntu. Specifically focusing on Ubuntu 20.04, the example provided will assist you in installing the PHP ext-json extension for your Ubuntu PHP setup. The article delves into the details of installing the PHP JSON extension on Ubuntu 20.04. Now, let's proceed with the steps.
To add the PHP JSON extension using the php-json library, use the following commands for various Ubuntu versions: 22.10, 22.04, 21.10, 21.04, 20.04, and 18.04 servers.
Install PHP Json Extension in Ubuntu 22.04
Run the following command:
sudo apt-get install php-json
Install PHP Json Extension For PHP 8.3
Run the following command:
sudo apt-get install php8.3-json
Install PHP Json Extension For PHP 8.2
Run the following command:
sudo apt-get install php8.2-json
Install PHP Json Extension For PHP 8.1
Run the following command:
sudo apt-get install php8.1-json
Install PHP Json Extension For PHP 8.0
Run the following command:
sudo apt-get install php8.0-json
Install PHP Json Extension For PHP 7.4
Run the following command:
sudo apt-get install php7.4-json
Install PHP Json Extension For PHP 7.3
Run the following command:
sudo apt-get install php7.3-json
Install PHP Json Extension For PHP 7.2
Run the following command:
sudo apt-get install php7.2-json
Restart Apache Server
Use the following command to restart the Apache2 server:
sudo service apache2 restart
Check php-json Extension Installed
Here, execute the following command to verify whether the extension is installed or not:
php -m | grep -i json
Verify the activation of the JSON extension by creating a PHP file containing the following content and accessing it through your web browser:
<?php
phpinfo();
?>
Inspect the section that references "json." If identified, the extension is successfully installed and active.
Take note that the package name (php-json) and web server commands may have slight variations based on your PHP version and web server. If there are any updates in Ubuntu 22.04, ensure to consult the official documentation or community resources for the latest information.
Your assistance is appreciated. If you have any further questions or need additional support, feel free to ask.