PHP - Failed to load mysql extension - php

OS: Sierra 10.12
PHP Version: 5.6.30
Originally I had a problem with ACPU module, after installing it using homebrew, it did not load properly, I used this article:
https://gist.github.com/andrewstobbe/7c56de552df41e444f0a1d5bdfa02ffe
And more specifically, I change line in httpd.conf file from this:
LoadModule php5_module libexec/apache2/libphp5.so
to this:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
ACPU, Xdebug and rest of modules works properly and they are visible in phpinfo(), but when I try to run one of projects, i've got an error:
Fatal error: Call to undefined function mysql_connect()
UPDATE:
I know that I should use mysqli instead, but i can't change this right now, mysql loads fine and works properly with original line in httpd.conf (LoadModule php5_module libexec/apache2/libphp5.so)

try
brew reinstall php56 --with-libmysql

Related

Apache gives error on start Library not loaded Reason: image not found even though the files exist

Suddenly, without any change, I get this error on apache start:
httpd: Syntax error on line 534 of /usr/local/etc/httpd/httpd.conf:
Cannot load /usr/local/opt/php#7.1/lib/httpd/modules/libphp7.so into server:
dlopen(/usr/local/opt/php#7.1/lib/httpd/modules/libphp7.so, 10):
Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
Referenced from: /usr/local/opt/php#7.1/lib/httpd/modules/libphp7.so
Reason: image not found
Checking for the files they do exist on the folders so I'm wondering why this error is occurring.
If I change on httpd.conf this line
LoadModule php7_module /usr/local/opt/php#7.1/lib/httpd/modules/libphp7.so
to
LoadModule php7_module /usr/libexec/apache2/libphp7.so
Apache does start but now the SQL PDO driver is not working like it used to be... Any thoughts why this error occurred in the first place or how to fix it properly?
you can try upgrading and re-installing the Homebrew PHP version should fix that. It worked for me with MacOS Mojave.
brew update
brew upgrade
brew reinstall php71
Then check if your httpd.conf is linked to this PHP:
LoadModule php7_module /usr/local/opt/php#7.1/lib/httpd/modules/libphp7.so
And, re-start apache:
sudo apachectl -k restart
As mentioned by #LuizEduardoMPF
brew update
and
brew upgrade resolved the issue for me. I didn't need to reinstall PHP or make any changes to the config file.
I'm using Mac os Mojave.
Just sharing what worked for me.

Homebrew PHP 7.1 (macOS Sierra) Apache Syntax Error

So I've been following along with This Tutorial, which helps configure Apache 2.4 with multiple versions of PHP. Everything was going quite smoothly, and all of my PHP versions worked, except for 7.1. When attempting to start the Apache server to receive the phpinfo of 7.1, I received the following error message:
httpd: Syntax error on line 178 of
/usr/local/etc/apache2/2.4/httpd.conf:
Cannot load /usr/local/opt/php71/libexec/apache2/libphp7.so into server:
dlopen(/usr/local/opt/php71/libexec/apache2/libphp7.so, 10): image not found
This is the code that exists on line 178:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
I tried running
brew reinstall php71 --with-httpd24
and restarted the Apache server. Still receiving the same error message. Any idea what went wrong? I appreciate any responses! Many thanks!
I had the same problem.
For me, homebrew has a different folder structure in /usr/local/opt where folders are more like /usr/local/opt/php#7.1
So I needed to find where libphp7.so lived, or if it existed at all.
Running find /usr -name "libphp7.so"
Came back with:
/usr/libexec/apache2/libphp7.so and
/usr/local/Cellar/php#7.1/7.1.15/lib/httpd/modules/libphp7.so
Both work in place of /usr/local/opt/php71/libexec/apache2/libphp7.so for me and I'll update if required in the future.
So I updated httpd.conf to use
LoadModule php7_module /usr/local/Cellar/php#7.1/7.1.15/lib/httpd/modules/libphp7.so
Then I restarted apache with sudo apachectl -k restart and all is well.
I'm getting this error with the brew install php. then
apachectl -t to test syntax
httpd: Syntax error on line 180 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so, 10): Symbol not found: _sqlite3_enable_load_extension\n Referenced from: /usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so\n Expected in: /usr/lib/libsqlite3.dylib\n in /usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so
For some reason??? I found the libphp7.so here
LoadModule php7_module /usr/libexec/apache2/libphp7.so
Plugged it in and it works.
However - I'm no clearer as to why the first one is failing.
Homebrew instructed to add this to my httpd.conf file:
LoadModule php7_module /usr/local/opt/php#7.1/lib/httpd/modules/libphp7.so
I tried stopping and restarting only to get the same error. After updating several times with different options, this one finally worked for me.
LoadModule php7_module /usr/libexec/apache2/libphp7.so
I had a PHP update, the file path has been changed. I changed the module path in httpd.conf.
Before:
LoadModule php7_module /usr/local/opt/php#7.4/lib/httpd/modules/libphp7.so
After:
LoadModule php7_module /usr/local/Cellar/php/7.4.12/lib/httpd/modules/libphp7.so
I had the same issue but with php 7.2.
Running brew linkage php showed that there were some broken dependencies.
So running brew update && brew upgrade resolved it for me.
in usr/local/opt there was an folder(alias) php only
`Just duplicate the php Alias-Folder and rename it to php#7.4`
after that
sudo apache graceful
I was done
I've changed the path of php7.4 on httpd.conf

Which versions/libraries do I need to get PHP running on Win 7 with Apache 2 (64bit)?

I have been having trouble getting PHP to install on my 64-bit Win 7 machine with Apache. I'm new to installing software that doesn't come shrink-wrapped and I have run out of useful docs/links to read.
Here is what I have done:
Installed Apache 2.4.18 win64 (which is built with VC14) from Apache Lounge. This works - my browser says "It works!" when I visit my docroot.
Downloaded the VC14 x64 Thread Safe (2016-Jan-06 23:30:09) PHP zip from windows.php.net and extracted it to c:/php.
Added LoadModule php5_module "c:/php/php7apache2_4.dll" to httpd.conf.
Downloaded VC_redist64.exe (version 14.0.23506) from Microsoft and installed it.
Tried httpd and I get:
c:\Apache24\bin>httpd
httpd: Syntax error on line 178 of C:/Apache24/conf/httpd.conf: Can't locate API module structure `php5_module' in file C:/php/php7apache2_4.dll: No error
I know I need to add/adjust more in httpd.conf and perhaps php.ini too, but all the help I have found on the web suggests that the problem is elsewhere.
LoadModule php5_module "c:/php/php7apache2_4.dll"
you should change it to:
LoadModule php7_module "c:/php/php7apache2_4.dll"
I replaced the LoadModule with a directive to load php5apache2_4.dll from the Wamp distribution and there seem to be no problems.
You're using PHP7, VC14. So instead of php5_module, use
LoadModule php7_module "c:/php/php7apache2_4.dll"
Result:
c:\Apache24\bin>httpd -t
Syntax OK
I looked all over the internet to get this fixed ... it was just a case-sensitive thing. I changed mine to:
LoadModule php7_module "c:/php/php7apache2_4.dll"
and it fixed the issue.

Specify PHP version in MAMP

Using Mamp 3.3, the conf/apache/httpd.conf file has the following line to specify PHP:
LoadModule php5_module /Applications/MAMP/bin/php/php5.6.10/modules/libphp5.so
When I update the line to a different version of PHP e.g.
LoadModule php5_module /Applications/MAMP/bin/php/php5.4.29/modules/libphp5.so
As soon as I restart MAMP it automatically resets it back to 5.6.10. Is there a way to force a PHP version?
Found a solution for this in MAMP forums. Just rename PHP versions not required. For example after renaming the following, they are not shown in the preferences:
/Applications/MAMP/bin/php/X_php5.6.10
/Applications/MAMP/bin/php/X_php5.4.42

Cannot start Apache (c:/php/php5apache2_4.dll into server: The specified module could not be found)

Well I tried to install PHP 5.5.9 and I followed the procedure in this video exactly: http://www.youtube.com/watch?v=6Y6lOHov3Bk
Basically I pasted these lines in the httpd.conf file, saved and restarted my computer.
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
And now when I try to start Apache it does not work, and the last line in the error log is the following.
(Cannot start Apache (c:/php/php5apache2_4.dll into server: The specified module could not be found)
The only thing I can think is that when I downloaded the PHP 5.5.9 zip file and unpacked it, it did not have the php5apache2_4.dll file so I had to download it from a 3rd party website: http://download12.mediafire.com/9ory5zibr0zg/ncwlddm9cclwc99/php5apache2_4.dll
You don't state whether you have x86 or x64, but the php5apache2_4.dll is only in the Thread Safe binary.
http://windows.php.net/download/
I faced same issue in windows 7 64bit Pro, when installed wampserver3.0.4_x64_apache2.4.18_mysql5.7.11_php5.6.19-7.0.4.exe.
The error in windows Event Viewer (though the file was there) :
The Apache service named reported the following error:
httpd.exe: Syntax error on line 184 of C:/wamp64/bin/apache/apache2.4.18/conf/httpd.conf: Cannot load c:/wamp64/bin/php/php5.6.19/php5apache2_4.dll into server: The specified module could not be found.
Soultion :
Try 1: First installed vc_redist.x64.exe as suggested by others (did not solve the problem)
Try 2:
Modified the below line in C:\wamp64\bin\apache\apache2.4.18\conf\httpd.conf
//old line
#LoadModule php5_module "c:/wamp64/bin/php/php5.6.19/php5apache2_4.dll"
//New line
LoadModule php7_module "c:/wamp64/bin/php/php7.0.4/php7apache2_4.dll"
After this WAMP can start, icon shows green, I can use for my developments.
Note : Another wamp related problem still exists in my system, when I click on the green wamp icon, the wamp menu does not open. I am researching now to resolve it.
The problem is that you need Microsoft VC++ 2012 distributable installed for PHP 5.6 to work. Once you install this, it should work fine for this.
Here is the configuration
LoadModule php5_module "c:/php/php5apache2_4.dll"
<IfModule php5_module>
# configure the path to php.ini
PHPIniDir "C:/php"
AddHandler application/x-httpd-php .php
</IfModule>

Categories