- PHP Fatal error: Call to undefined function curl_init() in /home/httpd/a/includes/functions.php(1)
- How to fix “Fatal error: Call to undefined function curl_init()”
- Installing CURL module for PHP on Ubuntu / Debian Linux
- RHEL/CentOS/ScientificAlmaLinux/Rocky Linux install CURL module for PHP
- OpenSUSE or SUSE Enterprise Linux
- Alpine Linux fixing Fatal error: Call to undefined function curl_init()
- FreeBSD Unix install CURL module for PHP
- Restart Apache/Nginx or PHP-FPM service
- Summing up
- Solved – Fatal error: Call to undefined function curl_init
- Check to see if curl is enabled.
- Enabling curl on Linux.
- Enabling curl on Windows.
- Enabling curl on WampServer.
- PHP Fatal error: Uncaught Error: Call to undefined function curl_init()
- Shared Hosting
- Install cURL extension for Apache/Nginx on Linux
- Check php.ini
- Windows
- Вызов неопределенной функции curl init () даже включен в php7
- 8 ответов
- Ошибка Call to undefined function curl_init()
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 or extenshion for PHP 5 or 7/8 version. 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.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | PHP on Linux/Unix |
Est. reading time | 2 minutes |
How to fix “Fatal error: Call to undefined function curl_init()”
Let us install curl extension on Linux or Unix.
Installing 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/7.x/8.x:
$ sudo apt-get install php-curl
Type the following apt-get command or apt command to install CURL module for PHP 7.x only:
$ sudo apt-get install php7.0-curl # php v7
$ sudo apt install php7.4-curl # php v7.4 for Ubuntu 20.04
RHEL/CentOS/ScientificAlmaLinux/Rocky Linux install CURL module for PHP
Run the following yum command or dnf command on Fedora box:
$ sudo yum install php-curl
$ sudo dnf install php-curl
You also try the following command:
$ sudo yum install php-common
The above should install php-common to enable curl support.
OpenSUSE or SUSE Enterprise Linux
Use the zypper command as follows:
sudo zypper in php7-curl
Alpine Linux fixing Fatal error: Call to undefined function curl_init()
Execute the following apk command to install extension:
# apk add php5-curl
OR
# apk add php7-curl
OR
# apk add php8-curl
FreeBSD Unix install CURL module for PHP
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
For PHP 8.x, run:
sudo pkg install php80-curl
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Restart Apache/Nginx or PHP-FPM service
Type the following command to restart nginx service:
$ 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 the following commands to restart php services:
# 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
To restart Apache 2 Web Server:
sudo systemctl restart apache2.service # Debian/Ubuntu
sudo systemctl restart httpd.service # RHEL/CentOS/Fedora
Summing up
You learned how to fix the error “Fatal error: Call to undefined function curl_init()” when using PHP with popular web servers such as Nginx, Apache, and others.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
Solved – Fatal error: Call to undefined function curl_init
This is a common error that occurs whenever PHP’s curl extension has not been installed or enabled.
The error will read something like this:
Fatal error: Call to undefined function curl_init()
Essentially, PHP can’t find the curl_init function because the extension that defines it has not been loaded. This results in a fatal error, which kills the PHP script.
To avoid this kind of error, you can check to see whether the cURL module has been loaded or not before you attempt to use it.
Check to see if curl is enabled.
To see if your PHP installation has curl enabled, you can run the following code:
The phpinfo function above will output information about PHP’s configuration.
If you do a CTRL + F search for curl and nothing is found, then it means that your PHP installation does not have curl enabled. If you do find it, then you should see the following line under the curl heading:
Note that you should NOT leave this phpinfo function on a live web server, as it outputs sensitive information about your PHP installation!
Enabling curl on Linux.
If your web server is running on Linux and you have SSH / terminal access, you can make sure that curl is installed by running the following command:
After running the command above, you will need to restart your web server so that the changes will take effect.
If you are using Apache, you can restart your web server like so:
If you are using Nginx, you can use the following command:
After your web server has been restarted, curl should be enabled.
Enabling curl on Windows.
If you are using Windows, you will need to locate the php.ini file that is being used by your web server. If you are unsure about which php.ini file you need to edit, then you can use the phpinfo script that we used above, as that will display the full path to the file that is being used by the web server.
Once you have located your php.ini file, you will need to “uncomment” the following line:
To uncomment the line above and enable the php_curl.dll extension, simply remove the semi-colon at the beginning.
After you have saved the changes that you made to your php.ini file, you will need to restart your web server. Otherwise, the new configuration will not take effect.
Enabling curl on WampServer.
If you are using the popular WampServer program on Windows, then you can try the following steps:
- Click on the WampServer icon in your system tray.
- Hover over the “PHP” option.
- Once the PHP menu appears, hover over the “PHP extensions” option.
- At this stage, a list of PHP extensions should appear. If an extension has a tick beside it, then it is already enabled. If the php_curl option does not have a tick beside it, then it is not enabled. To enable curl, simply click on the php_curl option.
- WampServer should automatically restart Apache and the changes should take effect.
- If WampServer does not automatically restart Apache, then you can manually force it to do so by clicking on the “Restart All Services” option in the main menu.
Hopefully, this guide helped you to get rid of that nasty “undefined function curl_init” error!
Источник
PHP Fatal error: Uncaught Error: Call to undefined function curl_init()
cURL is a PHP extension used to transfer data to or from a remote server. If the extension is not installed or enabled on your web server, you may get a fatal PHP error about an undefined function curl_init().
Shared Hosting
If you are on shared hosting and do not have command line access to your web server or access to php.ini, you may have to contact your web host to see if they support the cURL PHP extension. Many web hosts disable this extension by default for security reasons but may enable it manually for you on request.
Install cURL extension for Apache/Nginx on Linux
If you have shell access to your Apache or Nginx web server, make sure the cURL extension is installed:
You must also restart your web server for changes to take effect.
To restart Apache, run:
To restart Nginx, run:
Now test cURL with:
If you see some HTML, cURL is working correctly.
Check php.ini
If cURL is installed but you are still getting “Call to undefined function curl_init()”, you may need to enable the extension in your php.ini file.
In the example below, we are editing the php.ini file for Apache with PHP 7.2.
Press CTRL + W and search for curl .
Remove the ; semicolon from the beginning of the following line. This line may look different depending on your version of PHP, just remove the semicolon.
To save file and exit, press CTRL + X , press Y and then press ENTER .
You must restart your web server for changes to take effect.
To restart Apache, run:
To restart Nginx, run:
Now test cURL with:
If you see some HTML, cURL is working correctly.
Windows
If you’re on Windows, go to your php.ini file and search for “curl”.
Remove the ; semicolon from the beginning of the following line.
If you are on an older version of PHP, the line might look like below.
After you have saved the file you must restart your HTTP server software before this can take effect.
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
Источник
Вызов неопределенной функции curl init () даже включен в php7
Я только что установил php7 в свой Ubuntu. Сначала не было никаких проблем, мой веб-сайт работал. Но внезапно он начал возвращать вызов неопределенной функции curl_init () error. Теперь мои страницы содержат коды curl, которые не работают.
в phpinfo (), похоже, включен Curl. Там были похожие вопросы, но ни один из них не справился в php7. Я думал, что это должно быть что-то отличное от других.
изменить: Когда я пытаюсь
в терминале, это возвращает
8 ответов
у меня была аналогичная проблема с curl после обновления до XX (16.04). После переустановки curl с:
и перезапуск сервера
все вернулось в норму 🙂
в вашей системе может быть установлено несколько версий PHP, и Apache не использует версию, которую вы ожидаете использовать.
как узнать, какую версию PHP Apache использует?
чтобы узнать это, ключевая идея состоит в том, чтобы узнать корневой каталог файлов конфигурации Apache. В командной строке введите:
в моем случае Корневой каталог конфигурации Apache отображается в
теперь, когда я знаю расположение конфигураций, которые использует Apache, теперь я могу точно определить версию PHP, которую он использует, изучив «mods-enabled» каталог, расположенный внутри .
в моем случае, когда делать ls внутри «mods-enabled» , он показал выход ff:
на данный момент я точно знаю, что Apache использует ‘php5’ версия PHP установлена в моей системе, что бы это ни было.
затем я попытался воспроизвести ошибку выше, используя эту версию PHP (т. е. ‘php5’ ), выполнив команду ниже:
версия PHP, которую я ожидал, что мой Apache использовал, это «php5.6» и выполнение той же команды выше с этой версией не привело к указанной ошибке.
как сказать Apache, какая версия PhP для использовать?
вы можете сделать это с помощью a2enmod/a2dismod команды cli Apache2.
во-первых, я отключаю модуль PHP, который в настоящее время активен на моем сервере (т. е. «php5» ):
затем я включил модуль php для версии PHP, которую я хочу, чтобы мой Apache использовал:
затем я перезапускаю Apache
после того, как я обновил оскорбительную страницу на моем веб-сайте, ошибка теперь исчезла.
ваш путь к файлу, вероятно, неверен
Проверьте журнал ошибок Apache
если вызываемый путь или имя файла соответствует вашему реальному пути, например
в моем случае это был тот же путь, но «php_» отсутствовал
поэтому я изменил путь / имя файла соответственно в
для меня было решено обновить apt-get следующей командой, а затем установить php7.0-завиток.
ваши страницы, вероятно, не генерируются с помощью CLI SAPI. Проверьте, что phpinfo() возвращает при запуске с вашего веб-сервера (вероятно, пытается прочитать неправильный ini-файл).
- Шаг 1: Загрузите Php 7,
- Шаг 2 : скопируйте libeay32.dll и ssleay32.dll и мимо них C:\Windows\System32 — .
- Шаг 3 : Замените php_openssl.dll и php_curl.dll в C:\php\ext с последней dll. перезапустите apache
это исправило мою проблему с проблемами, надеюсь, кто-то тоже выиграет
Я знаю его очень поздний ответ, но я думаю, что это полезно, потому что я столкнулся с той же проблемой и попробовал все выше данное решение, но не работал. Затем я нажал следующую команду и теперь работаю отлично:
Я сделал все вышеперечисленное, но не решит проблему.
Env: Ubuntu, php7.1, Laravel 5.6
Источник
Ошибка Call to undefined function curl_init()
Доброго времени суток!
При попытке отправить данные с сервера выходит ошибка Fatal error: Call to undefined function curl_init()
Проверила на сервере наличие библиотеки php_curl.dll, она вроде бы есть, да и в php.ini строчка extension= php_curl.dll расскомментирована, а больше никаких советов по решению данной проблемы найти не смогла (на сервере стоит не Denwer).Не могли бы Вы подсказать, как исправить данную ошибку?
PHP Fatal error: Uncaught Error: Call to undefined function curl_init()
Всем привет! Знаю, проблема обсосана со всех сторон. Получаю вот это: PHP Fatal error: .
Ошибка: Call to undefined function printData() in
Я уже пытался читать проблемы людей со схожей тематикой, но т.к. в php я очень слаб, прошу мне.
Ошибка — Fatal error: Call to undefined function NOW()
Иннициализация: $d = NOW(); Результат: В чем может быть проблема? Это же не пользовательская.
Почему возникает ошибка? Call to undefined function: xmldoc()
Подскажите пожалуйста, почему возникает ошибка? 15
Посмотрите ошибку следующим кодом (что выдавать будет):
PHPВыделить код
$aOptionsCURL = array (
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST *=> ‘POST’,
CURLOPT_POSTFIELDS => $requestItem,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => false,
);
$sOptionsSessionCURL = curl_init();
curl_setopt_array ($sOptionsSessionCURL, $aOptionsCURL);
$sResultHTML = curl_exec($sOptionsSessionCURL);
if (curl_errno ($sOptionsSessionCURL)) <
echo ‘
cURL Error: ‘ . curl_error ($sOptionsSessionCURL);
Попробовала запустить эти функции на другом web-сервере, там почему-то все прошло нормально, хотя настройки на нем такие же, как и на первом.
Источник