For some reason my php extensions stopped working (they were working fine before).
curl for example:
curl_init();
returns an undefined function error.
In php.ini extension=php_curl.dll and extension_dir = "c:/wamp/bin/php/php5.5.12/ext/" are both set and correct.
extension_loaded('curl') returns false
Cant find anything useful in apache/php error log files. Tried resetting apache.
Im running Windows 8 64bit.
Any suggestions?
Try uncommenting this line PHPIniDir c:/wamp/bin/php/php5.5.12
Related
I have a simple test code:
<?php
var_dump(curl_init());
echo '.';
if I run it on command line (Windows 10) I get the expected result:
php.exe test.php
resource(4) of type (curl) .
very fine. But when Im running this file from browser (set to Apache rootdir).
Fatal error: Uncaught Error: Call to undefined function curl_init() in
Im speachless. For legacy reasons, this is php 7.04 (on 7.2, 7.4, 8.1 everything is fine).
The php.ini does work. Of course "extension=php_curl.dll" is enabled. When I change something, for example "max_execution_time = 300", the php_info(); also reinforcements me that these settings are taken into account.
However, the strange thing is what php_info() is saying:
cURL Sterling Hughes
nothing more for curl!
EDIT:
I tried the same with "extension=php_gd2.dll" and it does work if I remove/readd it, phpinfo shows that correctly!
This is because the php folder is not in your system PATH (not user), Apache doesn't know where to search dlls. The easiest way is adding php folder to PATH.
If you doesn't want to do that, you probably need set extension_dir to the full path of your extension folder in php.ini. for example:
extension_dir = "D:\Program Files\php-7.04-ts\ext"
cURL extension needs openssl to work. and you can also find these dlls in php folder, just copy them to Windows or system32 folder. According to RiggsFolly's comment you can copy these required dlls to Apache\bin folder.
libssl-1_1-x64.dll / libeay32.dll
libcrypto-1_1-x64.dll / ssleay32.dll
libssh2.dll
A simple php_curl example isn't working anymore on my Windows 10 laptop. It was working before.
Fatal error: Uncaught Error: Call to undefined function curl_init() in C:\Users\path\curl.php:3 Stack trace: #0 {main} thrown in C:\Users\path\curl.php on line 3
My C:\php7\php.ini has extension=C:\php7\ext\php_curl.dll
php_curl.dll exists in C:\php7\ext
PHP Version 7.0.30
Windows 10 Pro Version 1607 Build 14393.2189
But my loclahost/phpinfo.php does not have cURL. How come all of a sudden it disappeared ?
PS : The script worked in the command line. It's just that Apache is not loading the extension.
don't know why it suddenly stopped working, but first run <?php phpinfo(~0); , and check which php.ini file that is actually loaded (this avoids editing the wrong php.ini file to no avail) (in this example, it is /etc/php/7.0/fpm/php.ini), then edit that php.ini file, if that file actually has the extension=C:\php7\ext\php_curl.dll line, then some combination of the following settings are set wrong:
display_startup_errors is Off, change it to On
display_errors is Off, change it to On
error_reporting is not E_ALL, change it to error_reporting=E_ALL (and nothing else, not like error_reporting= E_ALL & ~E_NOTICE or whatever, just E_ALL)
html_errors is Off, change it to On
then restart apache, again check the phpinfo() page, and verify that the new configuration options are actually loaded, then run <?php curl_init();, and it should show an error about why the curl extension could not be loaded.
I came across some links on other StackOverflow answers (will post the links here if I trace them again). I had Apache 2.4.23 Win64 - I reinstalled Apache to the latest one - 2.4.33 Win64 - and now cURL is working.
I spent three hours but I did not find anything; I'm unable to connect to a SSL enabled server. I want to list what i did:
First checked my PHP extensions directory was in order; extension wasn't there, php_openssl.dll
Then I opened my php.ini file but I could not see any extension=php_openssl.dll line to uncomment.
Also, I searched on Google and saw people with the same problem.
http://www.apachefriends.org/f/viewtopic.php?p=162623
However, I also have
OPENSSL_CONF C:/xampp/apache/bin/openssl.cnf
...
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8l 5 Nov 2009
OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009
no lines . What should I do? Please share your suggestions.
Yes, you must open php.ini and remove the semicolon to:
;extension=php_openssl.dll
If you don't have that line, check that you have the file (In my PC is on D:\xampp\php\ext) and add this to php.ini in the "Dynamic Extensions" section:
extension=php_openssl.dll
[PHP_OPENSSL]
extension=php_openssl.dll
This is the answer.
Things have changed for PHP > 7. This is what i had to do for PHP 7.2.
Step: 1: Uncomment extension=openssl
Step: 2: Uncomment extension_dir = "ext"
Step: 3: Restart xampp.
Done.
Explanation: ( From php.ini )
If you wish to have an extension loaded automatically, use the following syntax:
extension=modulename
Note : The syntax used in previous PHP versions (extension=<ext>.so and extension='php_<ext>.dll) is supported for legacy reasons and may be deprecated in a future PHP major version. So, when it is possible, please move to the new (extension=<ext>) syntax.
Special Note: Be sure to appropriately set the extension_dir directive.
So, what did we do to make openssl_pkey_new() and all the other openssl_ functions in PHP work...
Enabled the extension php_openssl.dll in the (right/active) php.ini. Checked.
Checked that there exists a openssl.cnf in xampp\apache\conf\ (and also in two other directories within XAMPP). Checked.
Added the environment variable OPENSSL_CONF in the Windows system settings with the full path to the above openssl.cnf. Checked.
Restarted Apache (and after that did not work restarted the computer several times...). Checked.
Still does not work, and throwing errors such as
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:02001002:system library:fopen:No such file or directory
error:2006D080:BIO routines:BIO_new_file:no such file
Okay, here are another two more things to check.
1. Trouble with the environment
Run phpinfo() from a PHP script, and go to the "Apache Environment" section. Check the value of OPENSSL_CONF.
Surprise. This is not what we have set in the windows system settings.
The solution is simple. Set the environment variable in the PHP script.
putenv('OPENSSL_CONF=C:\xampp\apache\conf\openssl.cnf');
2. Trouble with relative filenames
Now, openssl_pkey_new() will work, but openssl_pkey_export_to_file() does still not work and returns false without any further explanation?
Check the filename that you have specified as output filename. It will not work in Windows as long as you do not specify the full path.
$folder = realpath('../keyring');
$outfile = $folder.'/private.pem';
openssl_pkey_export_to_file($key, $outfile);
I use xampp. Beforehand I tried the example file "test_smtp_gmail_basic.php" in phpMailer (you can download phpMailer here: https://github.com/Synchro/PHPMailer), but I got the following error:
Mailer Error: The following From address failed: xxx#gmail.com
After I commented out ; extension=php_openssl.dll in php.ini, it is working now.
In xampp, if "extension=php_openssl.dll" is not present in your php.ini file then add it in the "Windows Extensions" section of your php.ini file
and restart your apache.
It works for me..
You will need to edit your php.ini. It's 4 easy steps.
Find your php.ini file.
$inipath = php_ini_loaded_file();
Enable openssl in the file:
extension=php_openssl.dll
Turn allow_url_fopen on
allow_url_fopen = On
Restart apache and you are done!
STEP 1: On your php.ini comment out ;extension=php_openssl.dll
STEP 2: Copy libeay32.dll and ssleay32.dll from your PHP root folder and paste it your Apache/bin folder
STEP 3: Restart Apache
I am assuming that this question is for those using a windows based system.
After making sure that the extension extension=php_openssl.dll in your php.ini file does not have a semicolon.
Then make sure that you have added C:/xampp/apache/bin into your environment path in order to use openssl without having move the command prompt to that directory C:/xampp/apache/bin
Although not related to this question but as the WP migrate Pro docs link to this question I though I would post an answer here.
If your having problems with DB Migrate Pro activating instead of enabling SSL you can just add a line of code to your wp-config
define( 'WPMDB_LICENCE', 'XXXXXXXXXXx' );
I am using Windows 7, php 5.3.5 and WAMP server. I have two php files: trigger.php and background.php.
I want to run background.php as a background process. I have to call this file from trigger.php. To accomplish this I used below method.
I included following code in trigger.php to make background.php to process in background.
$handle = popen('start /b C:\wamp\bin\php\php5.3.5\php.exe C:\wamp\www\email3.php','r');
in background.php I have the follwing code to connect to database.
$conn_string = "host=localhost port=5432 dbname=tagbase user=postgres password=postgres";
now, on parsing this line am getting the follwing error :
Fatal error: Call to undefined function pg_connect() in C:\wamp\www\background.php on line 3 Call Stack: 0.0002 322792 1. {main}() C:\wamp\www\background.php:0
By searching in in the internet I found some solutions, and made changes as recommended below in php.ini,
uncommented, extension=php_pdo_pgsql.dll,
uncommented, extension=php_pgsql.dll,
uncommented, extension_dir = "c:/wamp/bin/php/php5.3.5/ext/",
also I do have php_pdo_pgsql.dll and php_pgsql.dll files in c:/wamp/bin/php/php5.3.5/ext/ folder.
Any suggestions are appreciated.
Apache 2.2.X configuration
Add the next line to the Apache 2.2.x httpd.conf configuration:
LoadFile "C:/Program Files/PostgreSQL/{version}/bin/libpq.dll"
Above line must be entered before the next line.
LoadModule php5_module "c:/wamp/bin/php/php5.2.11/php5apache2_2.dll"
PHP 5.2.X Configuration
Enable the following two lines in the php.ini configuration file. By 'Enable' i mean, remove trailing ; (semicolon). By these, you un-comment the line.
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
Restart WAMP
Test by adding this in your index.php
echo extension_loaded('pgsql') ? 'yes':'no';
(source: http://www.plaatsoft.nl/wamp-postgresql-integration/)
if we install WAMP server, we will get two php.ini files.
one in C:\wamp\bin\php\php5.3.5 and another in C:\wamp\bin\apache\Apache2.2.17\bin.
if we execute a php file from browser, then php.ini file in C:\wamp\bin\apache\Apache2.2.17\bin will be referred.
if we execute a php file from command line, then php.ini file in C:\wamp\bin\php\php5.3.5 will be referred.
what ever the changes i made enable/disable the dll in PHP->PHP extensions,all the changes will be saved in
C:\wamp\bin\apache\Apache2.2.17\bin\php.ini file. but C:\wamp\bin\php\php5.3.5\php.ini file remains unchanged.
for my problem, i made the following changes
uncommented, extension=php_pdo_pgsql.dll,
uncommented, extension=php_pgsql.dll,
uncommented, extension_dir = "c:/wamp/bin/php/php5.3.5/ext/",
in C:\wamp\bin\php\php5.3.5\php.ini file. Now its working good. :)
In my case with
Apache/2.4.10
PHP Version 5.4.32
PostgeSQL 9.3
I added libpq.dll into Apache httpd.conf from PHP catalog because Apache refused to start with libpq.dll from PostgreSQL 9.3
I'm using WAMP and trying to run something like the following:
<?php
$ldap = ldap_connect("ldap.example.com");
$user = "exampleUser";
$pass = "examplePass";
if($bind = ldap_bind($ldap, $user, $pass)) {
// logged in
} else {
// error message
}
?>
Before doing this though, I tried running phpinfo() to see if ldap was installed, and it doesn't appear anywhere.
I've tried the following:
Uncommented the following line in php.ini: extension=php_ldap.dll
Copied these files into the same directory as php.ini: ssleay32.dll
and libeay32.dll
Added the following to my environment variables: C:\wamp\bin\php
Restarted after doing any of these.
I don't really know what I'm doing, but these were the suggestions I found online. Any help would be appreciated!
This answer may be useful for others who come across this question as it's over a year since the OP posted this question.
I'm running
WAMP Version: 2.4
Apache Version: 2.4.4
PHP Version: 5.4.16
I tried most suggested solutions that a Google search will bring you to and nothing seemed to work. A forum recommended looking at the PHP pages
A user by the name of Frank in the above link recommended to copy libsasl.dll to [apache folder]\bin despite this only being recommended for earlier versions of php, this file is in the php folder.
copy "C:\wamp\bin\php\php5.4.16\libsasl.dll" "C:\wamp\bin\apache\apache2.4.4\bin\libsasl.dll"
This is what worked for me and LDAP is now showing up when I use phpinfo(), although I haven't properly tested it yet besides running the ldap_connect() function, but I'm assuming that means it is working and I should be able to use it in my application.
Besides adding libsasl.dll to the Apache bin I added C:\wamp\bin\apache\Apache2.4.4\bin and C:\wamp\bin\php\php5.4.16 to my PATH (i.e. the Windows environment variables -> system variables -> path) and I added ssleay32.dll and libeay32.dll to the both the Apache and php bin, not sure if required but it's working now.
What errors do you get? function does not exist?
Also you should add the following lines after your ldap_connect function:
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_DEBUG_LEVEL, 7);
if(!$ldap){
echo "LDAP Failed To Connect: ".ldap_error($ldap);
}
The options set ldap to protocol version 3, which is needed for active directory and alike on server 2k3 and alike and enabled debugging on the ldap connection.
Update
Also, run phpinfo() and look for the extensions directory. Navigate to that directory and make sure that php_ldap.dll exists in there.
I simply copied 'libsasl.dll' from the php directory to the apache directory and obviously restarted httpd. This solved my problem.
This was not a WAMP installation, I installed apache and php separately. Perhaps in case of WAMP or LAMP some more files can be needed.
I resolved the same problem by adding the php folder in the following Windows system path:
at command prompt
SET PATH=C:\wamp\bin\php\php5.3.13;%PATH%
it's very too late, but i had the problem and i wanted to add that you must uncomment extension=php_ldap.dll in both php and apache's php.ini.