I am aware that there are other questions with a similar title, such as the following:
curl_init() function not working
However I am still not able to get curl working on my localhost and on my server.
For this case, I will focus on the server, which is a Windows Server 2019.
The version of Apache is 2.4.46.
The version of PHP is 7.4.12.
In the php.ini file, I have the following uncommented:
extension=curl
In the extension folder, I can see the following file:
php_curl.dll
On the phpinfo.php page, I don't see that curl has been enabled, which is strange. The only place I see curl is in the module.authors section, and it looks like this:
cURL | Sterling Hughes
I have already restarted the services, but I am still getting the following error:
Fatal error: Uncaught Error: Call to undefined function curl_init()
What am I doing wrong and how can I fix this?
Edit
I just added this piece of code:
echo "<pre>", print_r(get_loaded_extensions()), "</pre>";
And I get the following:
Array
(
[0] => Core
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => date
[5] => filter
[6] => hash
[7] => iconv
[8] => json
[9] => SPL
[10] => pcre
[11] => readline
[12] => Reflection
[13] => session
[14] => standard
[15] => mysqlnd
[16] => tokenizer
[17] => zip
[18] => zlib
[19] => libxml
[20] => dom
[21] => PDO
[22] => openssl
[23] => SimpleXML
[24] => xml
[25] => xmlreader
[26] => xmlwriter
[27] => apache2handler
[28] => mysqli
[29] => Phar
[30] => pdo_mysql
)
1
None of which are for curl.
I was able to finally solve this issue by finding a file in my PHP root folder called libssh2.dll and copy/paste into the Apache bin folder. Once I did that, curl is now enabled, and I no longer get the error in question. I'm getting other errors, but that's for another question.
Related
Using php-5.4. I'm trying to load 'oci8.so' to access the function oci_connect. When in command line, I can access said function fine. But (after reloading, restarting, and reloading) php-fpm REFUSES to load the extension.
php -r 'print_r(get_loaded_extensions()); lists oci8.
Array
(
[0] => Core
[1] => date
[2] => ereg
[3] => libxml
[4] => openssl
[5] => pcre
[6] => zlib
[7] => bz2
[8] => calendar
[9] => ctype
[10] => hash
[11] => filter
[12] => ftp
[13] => gettext
[14] => gmp
[15] => SPL
[16] => iconv
[17] => pcntl
[18] => readline
[19] => Reflection
[20] => session
[21] => standard
[22] => shmop
[23] => SimpleXML
[24] => sockets
[25] => exif
[26] => tokenizer
[27] => xml
[28] => curl
[29] => fileinfo
[30] => json
[31] => oci8
[32] => Phar
[33] => zip
[34] => mhash
)
However curl localhost/extensions.php reads
Array
(
[0] => Core
[1] => date
[2] => ereg
[3] => libxml
[4] => openssl
[5] => pcre
[6] => zlib
[7] => bz2
[8] => calendar
[9] => ctype
[10] => hash
[11] => filter
[12] => ftp
[13] => gettext
[14] => gmp
[15] => SPL
[16] => iconv
[17] => Reflection
[18] => session
[19] => standard
[20] => shmop
[21] => SimpleXML
[22] => sockets
[23] => exif
[24] => tokenizer
[25] => xml
[26] => cgi-fcgi
[27] => curl
[28] => fileinfo
[29] => json
[30] => Phar
[31] => zip
[32] => mhash
// missing oci8
// and also missing 'pcntl'??
)
Both the fpm and cli are reading the exact same php.ini. I have check and tested.
Nothing at all in any error logs.
Well not sure it is related but this happened to me on "Amazon Linux 2 AMI" so I guess could apply to "CentOS" too.
Long story short I installed composer and other php stuff.
[zzzz#stageOpenID /etc/httpd/sites-enabled]$ php -i
phpinfo()
PHP Version => 7.2.30
System => Linux stageOpenID 4.14.177-139.254.amzn2.x86_64 #1 SMP Thu May 7 18:48:23 UTC 2020 x86_64
Build Date => May 5 2020 18:04:39
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
Additional .ini files parsed =>
So far so good.
And now to the web.
From phpinfo.php:
PHP Version: 7.2.30
System: Linux stageOpenID 4.14.177-139.254.amzn2.x86_64 #1 SMP Thu May 7 18:48:23 UTC 2020 x86_64
Build Date: May 5 2020 18:06:20
Server API: FPM/FastCGI
Virtual Directory Support: disabled
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
Additional .ini files parsed
But the lists are different.
Why? Simply because after the yum installation I restarted httpd but I forgot to restart php-fpm, so php-cli got the new modules and php-fpm didn't.
So, don't forget to:
sudo systemctl restart php-fpm
Depending how you have installed PHP FPM but, On Debian CLI and FPM use different ini files try:
php -i | grep php.ini
Mines is /etc/php/7.0/cli/php.ini
and
<?php phpinfo(); ?>
Mine is /etc/php/7.0/fpm/php.ini
Hope this helps.
Im trying to setup PDO to connect to an MSSQL database with XAMPP, I am running PHP 7, ive spent quite alot of time traversing the internet to try and overcome " Uncaught exception 'PDOException' with message 'could not find driver'"
error but so far im having no luck.
The drivers i am using were obtained from: HERE (v4.0)
And have installed the Microsoft OCDB driver 13 from: HERE
I have installed Microsoft Visual C++ 2015 aswell but i am still getting the same error, this is what ive tried so far.
I began by downloading the drivers designed for PHP7, i installed them into:
C:\xampp\php\ext
after which i added the extensions into the php.ini file located: C:\xampp\php
extension=php_sqlsrv_7_ts_x64.dll
extension=php_pdo_sqlsrv_7_ts_x64.dll
extension=php_sqlsrv_7_nts_x64.dll
extension=php_pdo_sqlsrv_7_nts_x64.dll
trying both the thread safe and non thread safe.
ive also set the extension_dir to the correct folder.
<?php
$path = php_ini_loaded_file();
echo 'The loaded file path is :' . $path;
echo '<br><br>';
$loadedExt = get_loaded_extensions();
print_r ($loadedExt);
$db = new PDO('sqlsrv:host=********;dbname=******;charset=utf8', 'username', 'password');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
This is the code i am using ^^, upon execution i am given this:
The loaded file path is :C:\xampp\php\php.ini
Array ( [0] => Core [1] => bcmath [2] => calendar [3] => ctype [4] => date [5] => ereg [6] => filter [7] => ftp [8] => hash [9] => iconv [10] => json [11] => mcrypt [12] => SPL [13] => odbc [14] => pcre [15] => Reflection [16] => session [17] => standard [18] => mysqlnd [19] => tokenizer [20] => zip [21] => zlib [22] => libxml [23] => dom [24] => PDO [25] => bz2 [26] => SimpleXML [27] => wddx [28] => xml [29] => xmlreader [30] => xmlwriter [31] => apache2handler [32] => openssl [33] => curl [34] => fileinfo [35] => gd [36] => gettext [37] => mbstring [38] => exif [39] => mysql [40] => mysqli [41] => pdo_mysql [42] => pdo_sqlite [43] => Phar [44] => mhash )
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\xampp\htdocs\BasicPDO\index.php:20 Stack trace: #0 C:\xampp\htdocs\BasicPDO\index.php(20): PDO->__construct('sqlsrv:host=col...', 'paisjd3', 'Famousrat6') #1 {main} thrown in C:\xampp\htdocs\BasicPDO\index.php on line 20
i am still getting the same error each time ive tried many different solutions to try and overcome this problem but still cant seem to figure this out, im realitively new to php so any help you could provide would be much appreciated.
Thanks,
Jack.
EDIT: Still looking for some help with this if anyone can provide any insight it would be greatly appreciated.
i am completely new to Google app engine. Im trying to host my wordpress blog using app engine. I tried some simple PHP scripts with app engine and everything goes well. But when i tried to load wordpress using app engine in my windows system, It is showing the error as,
"Your PHP installation appears to be missing the MySQL extension which is required by WordPress."
So i printed the loaded extensions in PHP using the get_loaded_extensions() php function, which outputs as follows,
Array
(
[0] => Core
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => date
[5] => ereg
[6] => filter
[7] => ftp
[8] => hash
[9] => iconv
[10] => json
[11] => mcrypt
[12] => SPL
[13] => odbc
[14] => pcre
[15] => Reflection
[16] => session
[17] => standard
[18] => mysqlnd
[19] => tokenizer
[20] => zip
[21] => zlib
[22] => libxml
[23] => dom
[24] => PDO
[25] => Phar
[26] => SimpleXML
[27] => wddx
[28] => xml
[29] => xmlreader
[30] => xmlwriter
[31] => cgi-fcgi
[32] => mhash
)
which shows that mysql is not loaded and i couldn't find any way to install it seperately since app engine does not allows it. But in app engine's documentation here, it is given that they are enabling mysql in app engine. So why the app engine not loading some extensions which is enabled by Google or is there any way to enable it manually? I don't know how to proceed further. Please help..
Note: I'm using Windows 7
That looks like the output from php installed on your machine, not the php in the app engine production environment.
You should be able to configure mysql to run locally following the instructions here: -> http://php.net/manual/en/mysql.installation.php
To see what extensions are available in production, run get_loaded_extensions() in the php shell here -> http://php-minishell.appspot.com/
I have enabled PHP 5.3.2 and Apache 2.2.14 on my install of Mac OS X Snow Leopard and have confirmed that I am connecting to it with a call to phpinfo();
On inital startup, it appears that ALL possible extensions are being loaded, as the call to print_r(get_loaded_extensions()) implies:
Array
(
[0] => Core
[1] => date
[2] => ereg
[3] => libxml
[4] => openssl
[5] => pcre
[6] => sqlite3
[7] => zlib
[8] => bcmath
[9] => bz2
[10] => calendar
[11] => ctype
[12] => curl
[13] => dom
[14] => hash
[15] => fileinfo
[16] => filter
[17] => ftp
[18] => gd
[19] => session
[20] => iconv
[21] => json
[22] => ldap
[23] => mbstring
[24] => standard
[25] => mysqlnd
[26] => SPL
[27] => odbc
[28] => mysqli
[29] => PDO
[30] => pdo_mysql
[31] => pdo_sqlite
[32] => Phar
[33] => posix
[34] => Reflection
[35] => mysql
[36] => shmop
[37] => SimpleXML
[38] => snmp
[39] => soap
[40] => sockets
[41] => SQLite
[42] => exif
[43] => sysvmsg
[44] => sysvsem
[45] => sysvshm
[46] => tokenizer
[47] => xml
[48] => xmlreader
[49] => xmlrpc
[50] => xmlwriter
[51] => xsl
[52] => zip
[53] => apache2handler
)
When I edited the php.ini.default and created the /private/etc/php.ini, I commented out all of the extensions available to prevent loading (for now I was just trying to get a baseline). Even after restarting Apache with the new php.ini info, all of the extensions are still loading. My guess is that since NO extensions are being explicitly loaded, PHP is reacting the same way it would if I had no php.ini.
What perplexes me is that when I attempt to find the library files associated with the "loaded" extensions, I can find NONE! I have searched my entire hard drive as root user looking for any trace of the *.so library files and have found none (ex: call to find / -name 'mysql' returns no files that are php extension libraries). And there is only one *.so file in the /usr/lib/php/extensions/no-debug-non-zts-20090626 directory listed as the extension_dir for php. Why would php say that is is successfully loading them then?
Here is the gd extension result from phpinfo() as an example: http://www.concentricsoft.com/downloads/phpinfo_sc1.jpg
I confirmed that the changes I made to the php.ini file took effect: I set the error_log= to a file and am able to write to it using a call to error_log($string, 0);
I have not tried to run code yet that would attempt to use any of the extensions that php says are loaded, so I guess that is my next move, but I just wanted to see if anyone else out there solved this issue and if so how.
Many PHP extensions can be built statically, as part of the php executable instead of as shared object files.
You can even build PECL extensions statically.
I have to install big CMS on my localhost, but it requires mcrypt, and pdo_mysql. Before I've tried to install them, I've tried to access site, but I only got blank page.
I'm running apache on windows, so I heard that I have to keep dll's in php extension folder. I've downloaded from dlldll.com (it's not ad) files php_pdo_mysql.dll, and php_mcrypt.php.
In php.ini I've uncommented lines "extension=php_mcrypt.dll", and "extension=php_pdo_mysql.dll". I've restarted apache... Blank again. And what now?
This is my get_loaded_extensions:
Array
(
[0] => bcmath
[1] => calendar
[2] => com_dotnet
[3] => ctype
[4] => session
[5] => filter
[6] => ftp
[7] => hash
[8] => iconv
[9] => json
[10] => odbc
[11] => pcre
[12] => Reflection
[13] => date
[14] => libxml
[15] => standard
[16] => tokenizer
[17] => zlib
[18] => SimpleXML
[19] => dom
[20] => SPL
[21] => wddx
[22] => xml
[23] => xmlreader
[24] => xmlwriter
[25] => apache2handler
[26] => curl
[27] => gd
[28] => mbstring
[29] => mysql
[30] => mysqli
[31] => rar
[32] => zip
[33] => eAccelerator
)
What I did wrong?
Update:
Some progress - now I have PHP startup warning on apache restart. "Unble to load php_mcrypt.dll/php_pdo_mysql.dll" - but I have those files in this directory. Is it possible that corrupted are for PHP same as non existing?
make sure you have following two options set in php.ini
By default error reporting is Off and you get blank page.
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On