Last week, I was working on a client website to install the free Paypal gateway (PayPal & Braintree official Module). And a 500 internal error keeps coming up. Later, I turned on the debug mode and found that the issue was caused by the PHP curl. So, here is a step by step explanation on how you can solve the issue.
Server: Ubuntu 18.04
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
1. Check if there are multiple PHP installations on your server.
# locate bin/php
2. If there are multiple installations like it shows above, make sure you select the one you want to use by disabling others.
# sudo a2enmod php7.0 # sudo a2dismod php7.0
3. Once you have only 1 PHP version in use, you can install the curl for it. In this case, I installed the curl for php7.0 particularly. It is always a good idea to install the latest version, but here I am using PHP 7.0., so I will install the php7.0-curl.
# sudo add-apt-repository ppa:ondrej/php # sudo apt-get install php7.0-curl
4. Enable/Disable the PHP curl.
# phpenmod curl # phpdismod curl
5. Restart the apache2
# systemctl restart apache2
6. You can make a PHP file to test if the curl is properly installed and enabled. You can create and save the following code under “yourwebsite.com/check_curl.php”
<?php echo 'Curl: ', function_exists('curl_version') ? 'Enabled' . "\xA" : 'Disabled' . "\xA"; ?>
It took me a while to realize there are multiple PHP installations on the server. So, when I installed and enabled the latest curl (for PHP 7.2), it doesn’t work with the PHP 7.0. Hope that helps resolve your problem. Feel free to leave a comment below.