PHP Fatal error: Call to undefined function curl_init() in /home/httpd/a/includes/functions.php(1)

I

setup a LEMP (Linux, Nginx,MySQL, PHP ) stack. But, getting the following error in /var/log/nginx/error.log file:

PHP Fatal error: Call to undefined function curl_init() in /home/httpd/a/includes/functions.php(1)

How do I solve this problem on Linux server?

 

You need to install the CURL module for PHP 5 or 7. cURL is a library that lets you make HTTP requests in PHP. In order to use PHP’s cURL functions you need to install the libcurl package. To solve this problem install php-curl as per your Linux / Unix distro and restart the web-server or php-fpm service.

Install CURL module for PHP on Ubuntu / Debian Linux

Type the following apt-get command or apt command to install CURL module for PHP 5.x:

$ sudo apt-get install php-curl

 

Type the following apt-get command or apt command to install CURL module for PHP 7.x:

$ sudo apt-get install php7.0-curl

Install CURL module for PHP on RHEL/CentOS/Scientific Linux

Type the following yum command:

$ sudo yum install php-curl

 

OR

$ sudo yum install php-common

 

The above should install php-common to enable curl support.

Install CURL module for PHP on Alpine Linux

Type the following apk command:

# apk add php5-curl

 

OR

# apk add php7-curl

Install CURL module for PHP on FreeBSD Unix

To install the port for PHP 5.x:

# cd /usr/ports/ftp/php56-curl/ && make install clean

 

Or To add the package for PHP 5.x use the pkg command:

# pkg install php56-curl

 

To install the port for PHP 7.x:

# cd /usr/ports/ftp/php70-curl/ && make install clean

 

Or To add the package for PHP 7.x:

# pkg install php70-curl

Restart Apache/Nginx or PHP-FPM service

Type the following command to restart nginx:

$ sudo service nginx restart

 

OR

$ sudo /etc/init.d/nginx restart

 

OR

$ sudo systemctl restart nginx

 

OR

# rc-service nginx restart

 

If you are using php-fpm, enter:

# rc-service php-fpm restart

 

OR

# /etc/init.d/php7.0-fpm restart

 

OR

# /etc/init.d/php5.0-fpm restart

 

OR

$ sudo systemctl restart php7.0-fpm.service

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *