I try PHP Post Request inside a POST Request thinking it might be useful for me. My code is given below:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
from the index.php file and index2.php is another file in the same directory and when I open the page I get the following error in my error.log file:
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP Fatal error: Call to undefined function curl_init() in /var/www/testing1/index.php on line 5
What I want to do is to have a reservation form that send post request. Then I want to process post values and send again the post request to paypal.
You need to install CURL support for php.
In Ubuntu you can install it via
sudo apt-get install php5-curl
If you're using apt-get then you won't need to edit any PHP configuration, but you will need to restart your Apache.
sudo /etc/init.d/apache2 restart
If you're still getting issues, then try and use phpinfo() to make sure that CURL is listed as installed. (If it isn't, then you may need to open another question, asking why your packages aren't installing.)
There is an installation manual in the PHP CURL documentation.
For Windows, if anybody is interested, uncomment the following line (by removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
I got it working in ubuntu 16.04 by following steps.My php version was 7.0
sudo apt-get install php7.0-curl
sudo service apache2 restart
i got it from this link check here for more details
For Ubuntu:
add extension=php_curl.so to php.ini to enable, if necessary. Then sudo service apache2 restart
this is generally taken care of automatically, but there are situations - eg, in shared development environments - where it can become necessary to re-enable manually.
The thumbprint will match all three of these conditions:
Fatal Error on curl_init() call
in php_info, you will see the curl module author (indicating curl is installed and available)
also in php_info, you will see no curl config block (indicating curl wasn't loaded)
In my case, in Xubuntu, I had to install libcurl3 libcurl3-dev libraries. With this command everything worked:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Just adding my answer for the case where there are multiple versions of PHP installed in your system, and you are sure that you have already installed the php-curl package, and yet Apache is still giving you the same error.
curl_init() undefined even if php-curl is enabled in Php 7.
Had this problem but found the answer here: https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
Had to:
sudo a2dismod php7.0
And:
sudo a2enmod php7.2
Then:
sudo service apache2 restart
This was after a system upgrade to next version of Ubuntu. All the other answers I found were stale, due to a bad cert apparently on the PPA most of them pointed out, but would probably not have worked anyway. The real issue was disabling the old versions of php, apparently.
Found the solution here:
https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
To fix this bug, I did:
In php.ini file, uncomment this line: extension=php_curl.dll
In php.ini file, uncomment this line: extension_dir = "ext"
I restarted NETBEANS, as I was using Built-in server
I got this error using PHP7 / Apache 2.4 on a windows platform. curl_init worked from CLI but not with Apache 2.4. I resolved it by adding LoadFile directives for libeay32.dll and ssleay32.dll:
LoadFile "C:/path/to/Php7/libeay32.dll"
LoadFile "C:/path/to/Php7/ssleay32.dll"
LoadFile "C:/path/to/Php7/php7ts.dll"
LoadModule php7_module "C:/path/to/Php7/php7apache2_4.dll"
This answer is for https request:
Curl doesn't have built-in root certificates (like most modern browser do). You need to explicitly point it to a cacert.pem file:
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/cert/file/cacert.pem');
Without this, curl cannot verify the certificate sent back via ssl. This same root certificate file can be used every time you use SSL in curl.
You can get the cacert.pem file here: http://curl.haxx.se/docs/caextract.html
Reference PHP cURL Not Working with HTTPS
Step 1 :
C:/(path to php folder)/php.ini
enable extension=php_curl.dll
(remove the ; at the end of the line)
Step 2 :
Add this to Apache/conf/httpd.conf (libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder)
# load curl and open ssl libraries
LoadFile "C:/(path to php folder)/libeay32.dll"
LoadFile "C:/(path to php folder)/ssleay32.dll"
LoadFile "C:/(path to php folder)/libssh2.dll"
On newer versions of PHP on Windows, like PHP 7.x, the corresponding configuration lines suggested on previous answers here, have changed. You need to uncomment (remove the ; at the beginning of the line) the following line:
extension_dir = "ext"
extension=curl
(Trying to get Curl working via PHP and Apache on Windows...)
I kept getting an error saying:
Call to undefined function 'curl_init()'
I made sure I had enabled curl with this line in my php.ini file:
extension=php_curl.dll
I made sure the extension_dir variable was being set properly, like this:
extension_dir = "ext"
I was doing everything everyone else said on the forums and curl was not showing up in my call to phpinfo(), and I kept getting that same error from above.
Finally I found out that Apache by default looks for php.ini in the C:\Windows folder. I had been changing php.ini in my PHP installation folder. Once I copied my php.ini into C:\Windows, everything worked.
Took me forever to figure that out, so thought I'd post in case it helps someone else.
For PHP 7 and Windows x64
libeay32.dll, libssh2.dll and ssleay32.dll should not be in apache/bin and should only exist in php directory and add php directory in system environment variable. This work for me.
Obvisouly in php.ini you should have enable php_curl.dll as well.
RusAlex answer is right in that for Apache you have to install and enable curl and restart your apache service:
sudo apt-get install php5-curl
sudo service apache2 restart
On my Ubuntu Server with nginx and php5-fpm I however ran into the following problem. I had to restart nginx and php5-fpm like so:
sudo service nginx restart
sudo service php5-fpm restart
But I had non-working php5-fpm processes hanging around, which apparently is a bug in ubuntu https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376
So I had to kill all idle php5-fpm processes to able to restart php5-fpm so that the curl module is actually loaded
sudo kill <Process Id of php5-fpm Process)
function curl_int();
cause server error,install sudo apt-get install php5-curl
restart apache2 server .. it will work like charm
For linux you can install it via
sudo apt-get install php5-curl
For Windows(removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
On Ubuntu 18.04 these two commands solve my this problem.
sudo apt-get install php5.6-curl //install curl for php 5.6
sudo service apache2 restart //restart apache
Seems you haven't installed the Curl on your server.
Check the PHP version of your server and run the following command to install the curl.
sudo apt-get install php7.2-curl
Then restart the apache service by using the following command.
sudo service apache2 restart
Replace 7.2 with your PHP version.
I also faced this issue. My Operating system is Ubuntu 18.04 and my PHP version is PHP 7.2.
Here's how I solved it:
Install CURL on Ubuntu Server:
sudo apt-get install curl
Add the PHP CURL repository below to your sources list:
sudo add-apt-repository ppa:ondrej/php
Refresh your package database
sudo apt update
Install PHP-curl 7.2
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath
Restart Apache Server
sudo systemctl restart apache2
That's all.
I hope this helps
Yet another answer ...
If you land here in Oct 2020 because PHP on the command line (CLI) has stopped working, guess what ... some upgrades will move you to a different/newer version of PHP silently, without asking!
Run:
php --version and you might be surprised to see what version the CLI is running.
Then run:
ll /usr/bin/php and you might be surprised to see where this is linking to.
It's best to reference the SPECIFIC version of PHP you want when calling the PHP binary directly and not a symbolic link.
Example:
/usr/bin/php7.3 will give you the exact version you want. You can't trust /usr/bin/php or even just typing php because an upgrade might switch versions on you silently.
I have solved this issue in Ubuntu 20.04.1 LTS and PHP Version 7.4.3
Update the package index:
sudo apt-get update
Install php7.4-curl deb package:
sudo apt-get install php7.4-curl
This worked for me with raspian:
sudo apt update && sudo apt upgrade
sudo apt install php-curl
finally:
sudo systemctl restart apache2
or:
sudo systemctl restart nginx
To install the last version of php-curl on Ubuntu, use this:
sudo apt-get install php-curl -y
Related
I have a problem with phpmyadmin on ubuntu 12.04.
I have already installed apache2, php5, mysql and phpmyadmin.
The phpinfo(); script, don't show nothing about mysqli or mysql extension.
When I try start phpmyadmin this error appear:
----
**phpMyAdmin - Error**
-------
**The mysqli extension is missing. Please check your PHP configuration.**
----
In the php.ini file, I uncommented extension=mysql.so line, but doesn't work...
Anyone have another posible solution?
Latest phpMyAdmin versions require mysqli extension and will no longer work with mysql one (note the extra "i" at the end of its name).
For PHP 7.3
sudo apt-get install php7.3-mysqli
For PHP 8
sudo apt-get install php8.0-mysqli
Will install package containing both old one and the new one, so afterwards all you need to do is to add
extension=mysqli.so
in your php.ini, under the subject Dynamic Extensions.
Restart apache:
sudo systemctl restart apache2
Authenticate if needed and press enter.
Should be done! If problem still occurs remove the browser cache.
sudo apt-get install php5-mysql
sudo apt-get install php5-mysqlnd
try both of alternatively it works for me
If you run PHPMyAdmin on localhost uncomment in file /etc/php5/apache2/php.ini this line:
mysqli.allow_local_infile = On
Restart Apache:
sudo /etc/init.d/apache2 restart
Just restart the apache2 and mysql:
apache2: sudo /etc/init.d/apache2 restart
mysql: sudo /etc/init.d/mysql restart
then refresh your browser, enjoy phpmyadmin :)
I tried a lot of the answers and none of them seemed to work because php7.0 is not the default.
sudo apt-get upgrade
seemed to do the job for me but I had to reinstall php7.0 and phpmyadmin after that:
sudo apt-get install php7.0 php7.0-mysql
sudo apt-get install apache2 apache2-mod-php7.0
sudo apt-get install phpmyadmin
Hope it helps!
I faced same issue and resolved it by doing following steps:
First check PHP versions. If you have multiple PHP Versions. Suppose you have PHP versions like php7.0, php7.1 and php 7.2 then
run these commands
For PHP7.0
sudo apt-get install php7.0-mysql
sudo apt-get install php7.0-mysqlnd
For PHP7.1
sudo apt-get install php7.1-mysql
sudo apt-get install php7.1-mysqlnd
For PHP7.2
sudo apt-get install php7.2-mysql
sudo apt-get install php7.2-mysqlnd
For PHP7.3
sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-mysqlnd
Edit the ini file and look for mysqli. Uncomment the line by removing ;
for all php versions
extension=mysqli.so
/etc/php/<php.version>/apache2/php.ini
For PHP7.0
sudo nano /etc/php/7.0/apache2/php.ini
For PHP7.1
sudo nano /etc/php/7.1/apache2/php.ini
For PHP7.2
sudo nano /etc/php/7.2/apache2/php.ini
For PHP7.3
sudo nano /etc/php/7.3/apache2/php.ini
and last restart apache server
sudo /etc/init.d/apache2 restart
I solved this problem by editing /usr/local/zend/etc/php.ini.
(found it by doing netstat -nlp ¦ grep apache, then strace -p somepid ¦ grep php.ini).
At the end of the file, I added:
extension=/usr/lib/php5/20090626+lfs/mysql.so
extension=/usr/lib/php5/20090626+lfs/mysqli.so
extension=/usr/lib/php5/20090626+lfs/mcrypt.so
Adding it without the path did not work.
Then after a restart it worked.
For ubuntu user open your terminal and type following command
sudo apt-get install mysql
After that just restart apache2 by typing this
sudo service apache2 restart
refresh you browser and enjoy phhmyadmin
For Ubuntu 20.04 users with php-fpm
I fixed the issue by adding the full path in the php conf:
edit /etc/php/7.4/fpm/conf.d/20-mysqli.ini
and replace
extension=mysqli.so
with:
extension=/usr/lib/php/20190902/mysqli.so
Checking the extension_dir is one of the thing you like to check from phpinfo().In my case it was extension_dir = "./" by default which was wrong. Change it to extension_dir = './ext/' or where all your extension dlls are currently residing.
Just add this line to your php.ini if you are using XAMPP etc. also check if it is already there just remove ; from front of it
extension= php_mysqli.dll
and stop and start apache and MySQL it will work.
You need the MySQLi module. This error usually occurs when manually installing phpMyAdmin.
sudo apt-get install php7.3-mysql
It will return you with.
[Creating config file /etc/php/7.3/mods-available/mysqlnd.ini with new version]
[Creating config file /etc/php/7.3/mods-available/mysqli.ini with new version]
Then.
sudo service apache2 restart.
Then.
Press F5 on your browser.
This worked for me , make a database with a php and mysql script and open up the mysql console and type in create user 'yourName'#'127.0.0.1' and then type in grant all privileges on . to 'yourName'#'127.0.0.1' then open up a browser go to localhost and a database should been made and then go to your phpmyadmin page and you will see it pop up there.
at ubuntu 12.04 i had to change mssql.compatability_mode = On.
put On and works
Since I had this problem following an upgrade, I just disable Apache2-php5
a2dismod php5
and activated php7
a2enmod php7
Hope it may help anybody!
I have encountered the same error on ubuntu and what worked for me was editing 2 lines in /etc/php/7.3/apache2/php.ini
;extension=mysqli to extension=mysqli
and gave the extension variable location to mysqli.so after uncommenting it
extension=/usr/lib/php/20170718/mysqli.so
then restart the service just to make sure
systemctl start mysql
For the record, my system is Ubuntu Server 20.04 and none of the solutions here worked. For me, I installed PHP 7.4 and I had to edit enter code here/etc/php/7.4/apache2/php.ini`.
Within this, search for ;extension=mysqli, uncomment and change mysqli to mysqlnd so it should look like this extension=mysqlnd. I tried using mysqli but I faced the same error as if I didn't enable it but mysqlnd worked for me.
Had the very same problem, but in my case the reason was update of Ubuntu and php version - from 18.04 and php-7.2 up to 20.04 and php-7.4.
The Nginx server was the same, so in my /etc/nginx/sites-available/default was old data:
server {
location /pma {
location ~ ^/pma/(.+\.php)$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
}
I could not get phpmyadmin to work with any of php.ini changes and all answers from this thread, but at some moment I had opened the /etc/nginx/sites-available/default and realised, that I still had old version of php. So I just changed it to
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
and the issue was gone, phpmyadmin magically started to work without any mysqli-file complaint. I even double checked it, but yeap, that's how it works - if you have wrong version for php-fpm.sock in your nginx config file, your phpmyadmin will not work, but the shown reason will be 'The mysqli extension is missing'
I hope my successful answer helps someone in recent times as I had to try many mix-and-matches and then found it:
This solution worked for me on Ubuntu 20.04 Desktop with PHP v7.4, PHP v8.0.7 and MySQL v8.0.25 setup.
What I did was edited /etc/php/7.4/apache2/php.ini and /etc/php/8.0/apache2/php.ini files and replaced
extension=mysqli.so
with
extension=/usr/lib/php/20190902/mysqli.so
in both the files.
Later, restarted both of these (PHP and MySQL) by sudo systemctl restart apache2 and sudo systemctl restart mysql. Refreshed Chrome, and phpMyAdmin responded with the login screen.
(UPDATE: Please check if you have /usr/lib/php/20200930/mysqli.so file as well. I tested this as it looked newer by directory date, and this too worked in both the PHP files as extension=/usr/lib/php/20200930/mysqli.so)
I have installed curl on Ubuntu 14.04 running PHP 5.6 with the following commands:
sudo apt-get install php5-curl
sudo service apache2 restart
It returns a successful message, but when I run:
php -m
the curl module is not listed, and phpinfo(); does not recognize it as installed or active. I also tried adding:
extension=curl.so
to my php.ini file, but that had no effect. How do I get PHP to recognize that curl is installed?
I got it working based on the second answer listed here: https://askubuntu.com/questions/9293/how-do-i-install-curl-in-php5
Basically:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5.6-curl
sudo service apache2 restart
I'm not really sure what made the difference. The repository reference is the most significant difference from previous attempts, but it seems odd as prior installation attempts didn't appear to have any problem accessing or installing/updating php-curl. And I had made sure everything was updated several times. But whatever it was, the above resolved it.
ssh to your server and cd to /
find / -name 'curl.so'
Run the above find command to locate where the curl binary is hanging out at. If you can't find the file, you might need to install curl and run the find command again.
apt-get install php5-curl
You'll now want to edit the php.ini being used for php files run from the cli (it's different than the one used by apache), and is likely at /etc/php5/cli/php.ini
nano /etc/php5/cli/php.ini
You can also run
php -i | grep 'php.ini'
To get the file path, just to be sure.
In your php.ini file search for [curl] by pressing ctrl + w
You'll now want to add the extension to the file and it should look something like the following, though your path to the curl.so file and such might be a little different:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =
extension=/usr/lib/php5/20131226/curl.so
After doing the above, I was able to use curl in php scripts run from the cli.
I am using php7.0. I have installed curl in my system.
I have this file:
/etc/php/7.0/cli/conf.d/20-curl.ini
I also have this file:
/etc/php/7.0/mods-available/curl.ini
Also, when I run this php -i | grep curl I get:
/etc/php/7.0/cli/conf.d/20-curl.ini,
curl
cat 20-curl.ini gives :
; configuration for php curl module
; priority=20
extension=curl.so
I even restarted my apache many times using sudo service apache2 restart
However, when I do var_dump(curl_init()) it says Call to undefined function curl_init().
I looked at various solution on stackOverflow, but can't find a solution that solves my problem. I am looking for the solution for hours. Can't understand how to make it work. I even tried sudo apt-get upgrade and upgraded my server.
I found in some solutions to uncomment ;extension=php-curl.dll but that is also not working. I am really stuck now. Need Help.
you modified php.ini for the cli executable, not the one used by apache.
you should have a etc/php7.0/apache2/php.ini file this is the one to update
The Solution is here: (I found the error in apache error log)
Although I shifted to php 7, I did not configure my apache to use php7 . So I did following:
sudo apt install php libapache2-mod-php
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart
I have a problem running phpMyAdmin. When I try to access phpMyAdmin in my browser, I get the error message: "The mbstring extension is missing. Please check your PHP configuration."
I have already searched on the internet for possible solutions. According to that, I made some modifications in php.ini file. I uncommented the line ";extension=php_mbstring.dll" and wrote the full path of the ext folder in extension_dir. Sadly, it still doesn't work.
Could you please help me finding the proper solution.
just run these command
sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo service apache2 restart
Or you can follow this post...
Check This Post
I've solved my problem by this way:
Edit the php.ini file:
change extension_dir = "ext" into extension_dir = "D:\php\ext" (please write ur own path)
change ;extension=php_mbstring.dll into extension=php_mbstring.dll (delete the ";")
Then just save your php.ini file and copy it to ur Windows directory。(“C:\Windows“)
restart the apache server。
The above is my solution,Hope it will work for u.
If you are ubuntu 14.04 and using php 5.6
You are missing out on mbstring and mysql module
Please install mbstring and mysql by
sudo apt-get install php5.6-mbstring
sudo apt-get install php5.6-mysql
and restart apache
sudo service apache2 restart
It could happen after you update your php version, for instance if you upgrade from php5.6 to php7.1 you need to run these commands:
sudo apt-get install php7.1-mbstring
sudo service apache2 restart
For php8.1
sudo apt-get install php8.1-mbstring
sudo systemctl restart nginx
If your destination version is different you need to check if the mbstring package exsit or not, an example for php7.0:
sudo apt-cache search php7.0-mbstring
I found it useful to first check existence of all modules that you working with, then performing an upgrade, in addition to that update phpmyadmin after upgrading your php is a good idea
In my case i made a new installation of php7 using xampp, the error was in php.ini at line 699, i just did
include_path= C:\Program Files (x86)\xampp\php\PEAR
to
include_path= "C:\Program Files (x86)\xampp\php\PEAR"
and it worked for me.
I checked this by running the php.exe it gave me that error and i fixed it.
Change extension_dir = "ext" to extension_dir = "C:/php/ext" in php.ini.
It could raise the concern if you're either:
Case 1: Downgrading/ upgrading any PHP version.
Case 2: Enabling/Disabling (Switching) between PHP versions.
Here are some recommended commands I found helpful to fix these concerns:
Message 1: The mbstring extension is missing.......
sudo apt-get install php7.1-mbstring
Message 2: The mysqli extension is missing.......
sudo apt-get install php7.1-mysqli
Note: Tested with PHP version 7.1. Change PHP version as per requirement.
I have solved my problem by this way:
Edit the c:\php\php.ini file:
change extension_dir = "ext" into extension_dir = "c:\php\ext" (please write
ur own path)
change ;extension=php_mbstring.dll into extension=php_mbstring.dll (delete
the ";")
restart the apache server。
I Hope it will work for u.
This worked for me on Kali-linux 2018 :
apt-get install php7.0-mbstring
service apache2 restart
You also need to define PHPIniDir - c:/php_install_path
You can try this
sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo ln -s /usr/share/phpmyadmin/ /var/www/html/phpmyadmin
service apache2 restart
this ones solved my problem
1.open command prompt in administration
then open apache bin folder like this,
c:\ cd wamp\bin\apache\apache2.4.17\bin>
then type after the above
c:\ cd wamp\bin\apache\apache2.4.17\bin> mklink php.ini d:\wamp\bin\php\php5.6.15\phpForApache.ini
thats it close the command prompt and restart the wamp and open it in admin mode.
original post : PHP: No php.ini file thanks to xiao.
before you do other way, please do open php.exe on your PHP folder.
run it and if you faced any error statement on it, you can fix it manually.
else, do most-usefull post in this thread.
I see this error after I disabled php5.6 and enabled php7.3 in ubuntu18.0.4
so i reverse it and problem resolved :DDD
This worked for me on Ubuntu with PHP 8:
sudo apt-get install php8.0-mbstring
I try PHP Post Request inside a POST Request thinking it might be useful for me. My code is given below:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
from the index.php file and index2.php is another file in the same directory and when I open the page I get the following error in my error.log file:
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP Fatal error: Call to undefined function curl_init() in /var/www/testing1/index.php on line 5
What I want to do is to have a reservation form that send post request. Then I want to process post values and send again the post request to paypal.
You need to install CURL support for php.
In Ubuntu you can install it via
sudo apt-get install php5-curl
If you're using apt-get then you won't need to edit any PHP configuration, but you will need to restart your Apache.
sudo /etc/init.d/apache2 restart
If you're still getting issues, then try and use phpinfo() to make sure that CURL is listed as installed. (If it isn't, then you may need to open another question, asking why your packages aren't installing.)
There is an installation manual in the PHP CURL documentation.
For Windows, if anybody is interested, uncomment the following line (by removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
I got it working in ubuntu 16.04 by following steps.My php version was 7.0
sudo apt-get install php7.0-curl
sudo service apache2 restart
i got it from this link check here for more details
For Ubuntu:
add extension=php_curl.so to php.ini to enable, if necessary. Then sudo service apache2 restart
this is generally taken care of automatically, but there are situations - eg, in shared development environments - where it can become necessary to re-enable manually.
The thumbprint will match all three of these conditions:
Fatal Error on curl_init() call
in php_info, you will see the curl module author (indicating curl is installed and available)
also in php_info, you will see no curl config block (indicating curl wasn't loaded)
In my case, in Xubuntu, I had to install libcurl3 libcurl3-dev libraries. With this command everything worked:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
Just adding my answer for the case where there are multiple versions of PHP installed in your system, and you are sure that you have already installed the php-curl package, and yet Apache is still giving you the same error.
curl_init() undefined even if php-curl is enabled in Php 7.
Had this problem but found the answer here: https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
Had to:
sudo a2dismod php7.0
And:
sudo a2enmod php7.2
Then:
sudo service apache2 restart
This was after a system upgrade to next version of Ubuntu. All the other answers I found were stale, due to a bad cert apparently on the PPA most of them pointed out, but would probably not have worked anyway. The real issue was disabling the old versions of php, apparently.
Found the solution here:
https://askubuntu.com/questions/1116448/cannot-enable-php-curl-on-ubuntu-18-04-php-7-2
To fix this bug, I did:
In php.ini file, uncomment this line: extension=php_curl.dll
In php.ini file, uncomment this line: extension_dir = "ext"
I restarted NETBEANS, as I was using Built-in server
I got this error using PHP7 / Apache 2.4 on a windows platform. curl_init worked from CLI but not with Apache 2.4. I resolved it by adding LoadFile directives for libeay32.dll and ssleay32.dll:
LoadFile "C:/path/to/Php7/libeay32.dll"
LoadFile "C:/path/to/Php7/ssleay32.dll"
LoadFile "C:/path/to/Php7/php7ts.dll"
LoadModule php7_module "C:/path/to/Php7/php7apache2_4.dll"
This answer is for https request:
Curl doesn't have built-in root certificates (like most modern browser do). You need to explicitly point it to a cacert.pem file:
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/cert/file/cacert.pem');
Without this, curl cannot verify the certificate sent back via ssl. This same root certificate file can be used every time you use SSL in curl.
You can get the cacert.pem file here: http://curl.haxx.se/docs/caextract.html
Reference PHP cURL Not Working with HTTPS
Step 1 :
C:/(path to php folder)/php.ini
enable extension=php_curl.dll
(remove the ; at the end of the line)
Step 2 :
Add this to Apache/conf/httpd.conf (libeay32.dll, ssleay32.dll, libssh2.dll find directly in php7 folder)
# load curl and open ssl libraries
LoadFile "C:/(path to php folder)/libeay32.dll"
LoadFile "C:/(path to php folder)/ssleay32.dll"
LoadFile "C:/(path to php folder)/libssh2.dll"
On newer versions of PHP on Windows, like PHP 7.x, the corresponding configuration lines suggested on previous answers here, have changed. You need to uncomment (remove the ; at the beginning of the line) the following line:
extension_dir = "ext"
extension=curl
(Trying to get Curl working via PHP and Apache on Windows...)
I kept getting an error saying:
Call to undefined function 'curl_init()'
I made sure I had enabled curl with this line in my php.ini file:
extension=php_curl.dll
I made sure the extension_dir variable was being set properly, like this:
extension_dir = "ext"
I was doing everything everyone else said on the forums and curl was not showing up in my call to phpinfo(), and I kept getting that same error from above.
Finally I found out that Apache by default looks for php.ini in the C:\Windows folder. I had been changing php.ini in my PHP installation folder. Once I copied my php.ini into C:\Windows, everything worked.
Took me forever to figure that out, so thought I'd post in case it helps someone else.
For PHP 7 and Windows x64
libeay32.dll, libssh2.dll and ssleay32.dll should not be in apache/bin and should only exist in php directory and add php directory in system environment variable. This work for me.
Obvisouly in php.ini you should have enable php_curl.dll as well.
RusAlex answer is right in that for Apache you have to install and enable curl and restart your apache service:
sudo apt-get install php5-curl
sudo service apache2 restart
On my Ubuntu Server with nginx and php5-fpm I however ran into the following problem. I had to restart nginx and php5-fpm like so:
sudo service nginx restart
sudo service php5-fpm restart
But I had non-working php5-fpm processes hanging around, which apparently is a bug in ubuntu https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376
So I had to kill all idle php5-fpm processes to able to restart php5-fpm so that the curl module is actually loaded
sudo kill <Process Id of php5-fpm Process)
function curl_int();
cause server error,install sudo apt-get install php5-curl
restart apache2 server .. it will work like charm
For linux you can install it via
sudo apt-get install php5-curl
For Windows(removing the ;) from php.ini
;extension=php_curl.dll
Restart apache server.
On Ubuntu 18.04 these two commands solve my this problem.
sudo apt-get install php5.6-curl //install curl for php 5.6
sudo service apache2 restart //restart apache
Seems you haven't installed the Curl on your server.
Check the PHP version of your server and run the following command to install the curl.
sudo apt-get install php7.2-curl
Then restart the apache service by using the following command.
sudo service apache2 restart
Replace 7.2 with your PHP version.
I also faced this issue. My Operating system is Ubuntu 18.04 and my PHP version is PHP 7.2.
Here's how I solved it:
Install CURL on Ubuntu Server:
sudo apt-get install curl
Add the PHP CURL repository below to your sources list:
sudo add-apt-repository ppa:ondrej/php
Refresh your package database
sudo apt update
Install PHP-curl 7.2
sudo apt install php7.2-fpm php7.2-gd php7.2-curl php7.2-mysql php7.2-dev php7.2-cli php7.2-common php7.2-mbstring php7.2-intl php7.2-zip php7.2-bcmath
Restart Apache Server
sudo systemctl restart apache2
That's all.
I hope this helps
Yet another answer ...
If you land here in Oct 2020 because PHP on the command line (CLI) has stopped working, guess what ... some upgrades will move you to a different/newer version of PHP silently, without asking!
Run:
php --version and you might be surprised to see what version the CLI is running.
Then run:
ll /usr/bin/php and you might be surprised to see where this is linking to.
It's best to reference the SPECIFIC version of PHP you want when calling the PHP binary directly and not a symbolic link.
Example:
/usr/bin/php7.3 will give you the exact version you want. You can't trust /usr/bin/php or even just typing php because an upgrade might switch versions on you silently.
I have solved this issue in Ubuntu 20.04.1 LTS and PHP Version 7.4.3
Update the package index:
sudo apt-get update
Install php7.4-curl deb package:
sudo apt-get install php7.4-curl
This worked for me with raspian:
sudo apt update && sudo apt upgrade
sudo apt install php-curl
finally:
sudo systemctl restart apache2
or:
sudo systemctl restart nginx
To install the last version of php-curl on Ubuntu, use this:
sudo apt-get install php-curl -y