I am getting this exception when trying to run my PHP unit tests:
Fatal error: Call to undefined function openssl_random_pseudo_bytes()
What does it mean?
I had the same issue. I solved it by editing my php.ini file - changing ;extension=php_openssl.dll to extension=php_openssl.dll .
(For my installation, my php.ini file was located in my P:\Program Files\EasyPHP-12.1\conf_files\ directory.)
Your version of PHP wasn't compiled with the openssl module. If you are building from source, add the module like so:
cd /path/to/php-5.4/
./configure --with-openssl
It means you do not have the openssl extension enabled in your PHP install. It needs to be enabled for you to use openssl_* functions.
It means you possibly don't have openssl enabled.
If you are on windows its even easier to load it. Enable it from wamp icon on system tray.
Check your configuration php.ini:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = "./"
; On windows:
extension_dir = "ext"
extension=php_openssl.dll
Your php installation either does not have openssl enabled, or you could be running a version of php < 5.3.
To enable openssl, you must re-compile and install php with the "–with-openssl" flag. See php installation documentation
For me this error occurred because i had not configured openssl correctly for my PHP.
This is the exact step i followed to rectify this error.
https://stackoverflow.com/a/36070260/1221096
Related
I have Xampp installed and want to work with sockets in php, so I started with the sample code from http://php.net/manual/en/sockets.examples.php on localhost.
I got this well known error:
Fatal error: Call to undefined function socket_create() in
C:\xampp\htdocs\simpletcpipserver.php on line 14
After searching the web I changed the PHP.ini files:
I removed the ; from extension=php_sockets.dll and edited this part to:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = C:\xampp\php\ext
php_sockets.dll is present at that location.
But still I get the same error.
I did see this on http://php.net/manual/en/sockets.installation.php:
The socket functions described here are part of an extension to PHP which must be enabled at compile time by giving the --enable-sockets option to configure.
Apart from what I already did, I don't understand what this means.
Would should I do now to get the sample code to work?
I try install Composer and it returns error: The openssl extension is missing. The recommended option is to enable the extension in your php.ini.
In php.ini string "extension=php_openssl.dll" is not commented out.
I use Denwer.
How can I solve my problem?
According with this Question: Composer Warning: openssl extension is missing. How to enable in WAMP WAMP (like Denwer) uses different php.ini for Apache and for CLI (PHP running in terminal, like composer).
As long I can see the php.ini file in Denwer is locate in "C:\WebServers\usr\local\php5\php.ini" and by default line "extension=php_openssl.dll" is commented (;), even uncommenting it PHP doesn't load OpenSSL.
In this site: http://hardmandev.com/article/nastroyka-openssl-dlya-denwer/ (In Russian) they suggest a way to make Openssl works on Denwer. According the feedback in the commentaries, this trick works.
I hope this can help you.
i have UwAmp installed.
and i'm using php cli command with composer, it says 'you must enable openssl extension'.
i'm sure i was enabled openssl in all php ini every version i have.
how to enable openssl for uwamp cli?
I had the same problem using UwAmp whilst trying to install composer, but found that I needed to add one more step before I could get it to work on my system.
After you identify the php_uwamp.ini file and copy it to the same directory as php.ini (as suggested) you need to find the following line
extension_dir = "{PHPEXTPATH}"
and change it to
extension_dir = "./ext"
The {PHPEXTPATH} variable is not interpreted when php is run under the CLI, and composer will complain about missing modules if you don't do this.
While asking this question I already found the answer:
Make sure openssl is enabled using the GUI
Find uwamp-directory/php/php-x.x.x/php_uwamp.ini
Copy it to php.ini in the same directory
Done.
If you use UwAmp, the installer Composer will struggle to find the php.ini file, even if you add the PHP folder to your PATH, because it just does not exist! The installer will display an error in the activation of the OpenSSL extension of PHP.
To resolve this issue, go to the folder of the PHP version used by UwAmp. Then copy the php_initial.ini file in the same folder and rename it to php.ini.
Then check the new php.ini the extension_dir variable is set to "ext", so you can install Composer normally.
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; On windows:
extension_dir = "ext"
original source for solution (in french):
http://baudet.me/2014/10/installer-et-utiliser-composer-avec-uwamp/
Not sure what happened, but below is what the log is giving me when trying to access phpmyadmin, please help. Trying to debug a different problem and ran into this. Not really possible to revert back to when it was working.
PHP Fatal error: Call to undefined function mb_detect_encoding() in
/usr/share/php/gettext/gettext.inc on line 177
When trying to go the the site, I get this error, I think it's likely the two errors are related:
Database connection error (1): The MySQL adapter 'mysqli' is not available.
First error is caused by php because the extension mbstring is either not installed or not active.
The second error is output of phpMyAdmin/your site asking you to install / enable the mysqli extension.
To enable mbstring and mysqli edit your php.ini and add/uncomment the two lines with mbstring.so and mysqli.so on unix or mbstring.dll and mysqli.dll on windows
Unix /etc/(phpX/)php.ini
extension=mysqli.so
extension=mbstring.so
Windows PHP installation folder\etc\php.ini
extension=mysqli.dll
extension=mbstring.dll
Don't forget to restart your webserver after this.
EDIT:
User added he was using redhat in the comments so here's how you install extensions on all CentOS/Fedora/RedHat/Yum based linux distros
sudo yum install php-mysqli
sudo yum install php-mbstring
restart your werbserver
sudo /etc/init.d/httpd restart
you can verify your installation with a little php script in your document root.
This lists all settings, versions and active extensions you've installed for php
test.php
<?php
phpinfo();
After reading about the extension_dir = "ext" i added the line to php.ini but didnt work, then started to look apache error log and saw the PHP was in fact unable to find the dll's in the specified directory "ext". I commented the extension_dir line, restarted Apache and looked the error log again, saw that PHP was now looking the dll's in C:/PHP/ext (by default i guess), but since im using other folders, that's not the correct path, so i uncommented the extension_dir line and wrote this:
extension_dir = "C:/Apache24/PHP/ext"
In my configuration that is the correct path to dll's.
and of course, uncommented:
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
Restarted the Apache server and internet browser and now phpMyAdmin works with my mySQL login.
So, dll's incorrect path and dll's needed commented in php.ini were the problem.
Remember to restart Apache and internet browser after editing config files.
System spec:
Windows 7 HB 64bit
httpd-2.4.4-win32-ssl_0.9.8.zip
php-5.4.16-Win32-VC9-x86.zip
phpMyAdmin-4.0.4.1-all-languages.zip
mysql-installer-community-5.6.11.0.msi
Hope this help. Thx for your comments too.
in ubuntu 16.04 when i tried to connect to phpmyadmin a white blank paged appeared so i ran the above command and phpmyadmin works
sudo apt-get install php-mbstring php7.0-mbstring php-gettext
for mysql support install
sudo apt-get install php7.0-mysql
tested in ubuntu 16.04 with php 7 version
It looks like your PHP installation does not have the mbstring extension and the mysqli adapter extension installed.
Please check your phpinfo(); or run php -i | grep 'mbstring\|mysqli' in a terminal.
I had the same problem on my windows7- 32 bit:
1."PHP Fatal error: Call to undefined function mb_detect_encoding() in /usr/share/php/gettext/gettext.inc on line 177"
when i opened my php.ini file , "extension_dir" line looked like following :
extension_dir = "C:/wamp/bin/php/php5.4.16/ext/"
which i changed to :
extension_dir = "C:\wamp\bin\php\php5.4.16\ext\"
and it worked.
In php.ini, I had to change
extension_dir = "ext"
to
extension_dir = "C:/PHP/ext"
as my PHP was installed in C:\PHP. I had to use / instead of \, and then it worked.
Also uncomment mbstrings, mysqli and mysql extensions.
What helped me (using XAMPP on Windows) was to:
make sure that my path included the correct path for PHP (I had two PHP
installations, one under c:\php and the XAMPP installation in
c:\xampp\php which was the one I wanted to use)
check that the lines
extension_dir="C:\xampp\php\ext" extension=php_mbstring.dll extension=php_exif.dll ; Must be after mbstring as it depends on it were uncommented in the php.ini file (i.e. no ; at the beginning)
restart the Apache server
last but not least, clear the cache when reloading the page http://localhost/phpmyadmin/ (for instance with Ctrl-F5 in Chrome)
Recompile PHP with mbstring.
./configure --enable-http --with-apxs2 --with-mysql --with-gd
--with-curl --with-mbstring
make
make install
My guess would be to check that the mysqli extension is enabled in your PHP configuration. More info would be great (eg. OS, AMP stack, etc.).
Check in your php.ini configuration for mysqli and make sure there is no ';' in front of the extension. The one enabled on my setup is php_mysqli_libmysql.dll.
Try to install mysqli and pdo.
Put it in terminal:
./configure --with-mysql=/usr/bin/mysql_config \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
I tried on Windows and I was getting same issue after enabling this in PHP installation folder\etc\php.ini:
extension=mysqli.dll
extension=mbstring.dl
You should also enable the following in the ini file:
extension_dir = "ext"
phpMyadmin is working now!
In windows 2008 Server.
i removed ";" in front of extension=php_mbstring.dll in php.ini file and it worked... i followed below link...
https://bugs.php.net/bug.php?id=64965
Some versions of windows do not come with libmysql.dll which is necessary to load the mysql and mysqli extensions. Check if it is available in C:/Windows/System32 (windows 7, 32 bits). If not, you can download it DLL-files.com and install it under C:/Windows/System32.
If this persists, check your apache log files and resort to a solution above which responds to the error logged by your server.
One options is:
disabled this extension_dir = "ext"
and the other is:
go to wamp icon and see php and the click on php error logs then from error log u can find exact error.
this error occurs only if paths are not properly set.
I had the same trouble, this is what worked for me.
You can click at the wampserver icon, then at the PHP error log.
Check if it says this:
Unable to load dynamic library 'c:/wamp/bin/php/php5.5.12/ext/php_ldap.dll'
If yes, then you can reload your version of PHP, by clicking at the wampserver icon, then PHP, then version, and then you click at your version.
Wait for everything to be online again, then try to access phpmyadmin.
I installed apache2 and php 5.4.5.
When you start apache this error:
PHP Warning: PHP Startup: in Unknown on line 0
The extension does not work:
; extension = php_intl.dll
; extension = php_ldap.dll
; extension = php_oci8.dll
; extension = php_oci8_11g.dll
; extension = php_pdo_firebird.dll
; extension = php_pdo_oci.dll
; extension = php_pdo_pgsql.dll
; extension = php_pgsql.dll
; extension = php_pspell.dll
; extension = php_shmop.dll
And maybe more.
Extensin dir: extension_dir = "C :/ dev/prog/php5/ext /"
Path: C: \ dev \ prog \ php5
php.ini is copied to C: \ WINDOWS \
ssleay32.dll php5ts.dll and is copied to C: \ WINDOWS \ system32 \
Please simple instructions.
upgrade those modules using pecl command
Also, Check extension_dir directive in php.ini
I had the same problem. The issue is, that these lines are by default in php.ini
; On windows:
; extension_dir = "ext"
I assumed, that only an uncomment of the second line and Apache restart solves this problem. But it isn't!
I had to type a full path to the ext folder, such as below:
extension_dir = "d:\php-5.4.32\ext"
After this action, and restart of the Apache web server, the problem was solved.
You should check you php.ini file to make sure the extension_dir is exactly set.
I had the same problem when i enable these five extensions:
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_curl.dll
The number of warnings is the same as the extensions that enabled.
So i guess may be there is sth. wrong with the extension setting.
When i change the extension_dir directive to the right dir, the problem resolved.
I found this answer in this post on the wampserver forums, and it worked for me:
Click on the Apache version that you use in the WAMPServer menu, e.g.
wampmanager -> Apache -> Version -> 2.4.9 ( just click on the version number on this menu item )
this will rebuild the SYMLINKS for the extensions that are causing the "in Unknown on line 0" error.
The answer was given by RiggsFolly in this thread: http://forum.wampserver.com/read.php?2,128734
I had the same problem when I enabled extensions (see Error when enabling PHP extensions).
I resolved it adding the PHP folder to the path and restarting the computer.
You need to download and install Aspell for Windows “GNU Aspell-0.50.3 (win32)”.
http://aspell.net/win32/
http://ftp.gnu.org/gnu/aspell/w32/Aspel ... -Setup.exe
Your Dictionaries are also here. Aspell needs at least one Dictionary to operate.
or
ftp://ftp.gnu.org/gnu/aspell/w32/
ftp://ftp.gnu.org/gnu/aspell/w32/Aspell ... -Setup.exe
ftp://ftp.gnu.org/gnu/aspell/w32/aspell-w32-0.50.3.zip
Aspell should copy the “aspell-15.dll” to the “Windows/System32” directory which the php entension php_pspell.dll requires and looks for to execute.
If not then locate aspell-15.dll in C:/Program Files/Aspell/bin/aspell-15.dll and copy it to C:/Windows/System 32/aspell-15.dll
You only need now to uncomment this line in:
xampp/apache/bin/php.ini
;extension=php_pspell.dll
to this:
extension=php_pspell.dll
Restart Apache.
(If Apache won't start paste the error message here).
Check the pspell module is in place and enabled by lookin at your phpinfo() file from the menu within the XAMPP Welcome Page. http://localhost/index.php
For more info visit https://community.apachefriends.org/f/viewtopic.php?p=83942
The problem is not coming from there, the problem is from the path (I mean %PATH% for Windows users, because of %PATH% is a variable that contains many paths separated by ;). So to figure out the problem you have to:
1-make configuration in the httpd.conf file:
PHPIniDir "${path}/conf_files"
2-make configuration in your php.ini file (it must be in the same location with the httpd.conf file):
change this:
extension_dir = "${path}\php\ext\"
To
extension_dir = "D:\EasyPHP5.3.0\php\ext\"
(in my case the php is installed in D:\EasyPHP5.3.0)
Optional:
if you need to execute PHP from the CLI (Command Prompt)
you have to make copy of the php.ini file to the folder when the PHP is installed (in my case D:\EasyPHP5.3.0\php)
Restart/Start your web Server and enjoy!
I had similar problem. cURL required SSL layer. Problem was in installation of php_curl library, see http://php.net/manual/en/curl.installation.php. The firs problem: libeay32.dll and ssleay32.dll are required on PATH. I put them in apache/bin directory. The second problem is that php.ini required php_openssl loaded before php_curl so I modified ini file.
extension=php_openssl.dll
extension=php_curl.dll
I solved the problem on my windows 7 with two steps:
set extension_dir as absolute path in php.ini
extension_dir = "d:\php-5.4.32\ext"
comment the php_curl.dll module in php.ini
;extension=php_curl.dll
Same problem was solved by changing to full path:
PHPIniDir in httpd.conf and extension_dir in php.ini.