A completed solution to Internal Server Error 500 caused by PHP Curl with Prestashop 1.7.4.2

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
Release: 18.04
Codename: bionic

Prestashop: 1.7.4.2
Paypal: 4.5.0.0

1. Check if there are multiple PHP installations on your server.

# locate bin/php 

/usr/bin/php

/usr/bin/php7.0

/usr/bin/php7.2

/usr/sbin/phpdismod

/usr/sbin/phpenmod

/usr/sbin/phpquery

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";
?>

Done.

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.



Leave a Reply