To be able to convert your PHP objects into JSON using the PHP functions, you need to have php-json
extension installed. Let’s install PHP Json on Amazon Linux 2.
Prerequisites
- Amazon Linux 2
- sudo privileges
- PHP installed
Install PHP Json on Amazon Linux 2
Step 1. Enable the desired PHP version.
sudo amazon-linux-extras enable php{version}
Step 2. Install php-json.
sudo yum clean metadata
sudo yum install php-json
Step 3. Restart your web server service.
Step 4. Verify the installation.
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Step 5. Open the file (info.php) in the browser.
http://server_ip/info.php
Conclusion
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.