Can't load apache php5 module with apache2.4 - php

I used Homebrew to install apache 2.4 and php 5.4 (also tried 5.6) (using Mac Osx Mavericks). When I try to load the php5 module I get the following error:
httpd: Syntax error on line 157 of /usr/local/apache-2.4.9/conf/httpd.conf: Cannot load /usr/local/opt/php56/libexec/apache2/libphp5.so into server: dlopen(/usr/local/opt/php56/libexec/apache2/libphp5.so, 10): Symbol not found: _unixd_config\n Referenced from: /usr/local/opt/php56/libexec/apache2/libphp5.so\n Expected in: /usr/local/apache-2.4.9/bin/httpd\n in /usr/local/opt/php56/libexec/apache2/libphp5.so
I tried re-installing php a few different ways I saw online with users having the same error, but to no avail:
brew install php55 --homebrew-apxs
brew install php56 --with-mysql --with-homebrew-apache
brew install -s php56
Anyone know how I could resolve this issue? Thanks in advance!

I was able to fix the issue by running the following:
brew install 56 --with-apache
I'm not sure if that's ideal way to fix and am still having an issue rendering the php page (which might be related to a separate issue), but hopefully this helps someone.

Related

Installing httpd and php in Mac OS 12

I updated my MacOS to Monterey (12.0.1) and my PHP stopped working.
MacOS 12 seem to have removed PHP support.
I'm currently trying to configure everything using homebrew.
After installation, when I try to start the httpd, I'm getting the following errors-
user#Laptop folder % /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
dyld[15738]: Symbol not found: _apr_bucket_file_set_buf_size
Referenced from: /opt/homebrew/Cellar/httpd/2.4.51/bin/httpd
Expected in: /usr/lib/libaprutil-1.0.dylib
zsh: abort /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
Am I missing any package for _apr_bucket_file_set_buf_size?
Yeah, what a nightmare! PHP is no longer supported natively in MacOS 12. I switched to Homebrew's Apache (httpd) package.
But switching from native Apache to Homebrew's Apache wasn't easy.
There are lots of guides out there on how to install Homebrew's Apache. I won't go into them here.
But after installing, configuring, and starting, I was receiving a similar error to your "apr_bucket" error. I ran brew reinstall apr-util and that did the trick.
Found it here: https://stackoverflow.com/a/41871228/1623341
After that, I removed Homebrew's Apache brew remove httpd, then reinstalled brew install httpd, then updated the httpd.conf file, then started brew services start httpd. That seemed to do the trick for me.
I had to sign the homebrew PHP module using MacOS codesign.
Finally, Apache and PHP are working in my MacOS Monterey.
Kudos to the original author for the detailed solution
https://www.simplified.guide/macos/apache-php-homebrew-codesign

Upgraded PHP version to 5.4.1, MAMP URLs broken, so downgraded but still broken?

OK, so (retrospectively, quite stupidly), I upgraded my mac osx PHP version (not mamp php) from 5.3.28 to 5.4.10, to try and install composer. Now my MAMP sites don't seem to be loading. (I am not a backender.)
1. I upgraded mamp
At the end of the upgrade the final messages in terminal were as follows:
Create symlink /usr/local/php5/entropy-php.conf /etc/apache2/other/+php-osx.conf
Restarting Apache
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.2 for ServerName
Syntax OK
But when I checked the php version in terminal, it still said 5.3.28.
2. MAMP start page loaded, sites didn't work
Suddenly none of my MAMP sites were working. I have set the virtual hosts in httpd-vhosts.conf (and using sudo vim /etc/hosts). These have been working for like 3 years with no problem.
MAMP still loads the start page, but when I load a site I get:
Not Found
The requested URL / was not found on this server.
Apache/2.2.26 (Unix) PHP/5.4.41 DAV/2 Server at domain.dev Port 80
3. Reinstalled MAMP
So I then uninstalled and reinstalled MAMP, and restored all my settings, which again still loads up fine (the MAMP php version is now 5.6.7).
4. Tried downgrading mac php back to 5.3.28
I then tried to downgrade back to PHP 5.3.28, but that wouldn't work when I tried to use:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.3.28
So I just used:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.3
And it appears to have downgraded to 5.3.29, but with the following error at the end:
Executing post-install script /tmp/5.3-frontenddev-post-install
Restarting Apache
httpd: Syntax error on line 665 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /etc/apache2/other/+php-osx.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): Symbol not found: _libiconv\n Referenced from: /usr/local/php5/lib/libintl.8.dylib\n Expected in: /usr/lib/libiconv.2.dylib\n in /usr/local/php5/lib/libintl.8.dylib
When I check the php version, it still says '5.3.28' :(
5. Someone save me
The exact same problem persists. I have no idea what's gone wrong or how to fix it. Any help would be super appreciated!
Running Mac Lion 10.7.5
OK. So MAMP then stopped working completely. But against all odds, I managed to fix it.
I followed this guide and reinstalled PHP 5.3:
http://benedmunds.com/php/2014/10/16/fixing-homebrew-php-apache-after-yosemite/
I got an error when I got to this line:
$ brew reinstall php53 --with-mysql --with-pgsql --with-apache
So I followed the beginning of this guide:
https://rtcamp.com/tutorials/mac/osx-brew-php-mysql-nginx/
Until I got to the install line tried it again to install 5.3:
brew search php
brew tap josegonzalez/php
brew tap homebrew/dupes
brew options php53
brew reinstall php53 --with-mysql --with-pgsql --with-apache
Took a little while, finished up. Restarted MAMP, and everything works again.
Phew.
Update
Had issues loading the MAMP start page too afterwards. Solved them by stopping OSX apache from running. It must have been taking over or something...
sudo apachectl stop

problems with php53-mcrypt brew

While trying to install mcrypt for php53, using homebrew, I'm running into this error:
$ php -i
dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Trace/BPT trap: 5
I've tried uninstalling/reinstalling libpng, switching to different versions of libpng, remove/reinstall php53-mcrypt, etc. I've now uninstalled both those with homebrew and it's giving the same error still. Haven't turned up any good results on google for solutions. Any ideas?
What fixed it for me was doing a brew re-install of PHP itself, so here are the steps:
brew reinstall php53
then restart apache:
apachectl stop
apachectl start

Error for Apache2.2.15 configuration with PHP5

I am trying to configure apache 2.2.15 with php5 in my linux system. I have installed both of them. But when I added libphp5.so module in httpd.conf of apache, it has given the following error while starting the server:
Starting httpd: httpd: Syntax error on line 202 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/libphp5.so into server: /etc/httpd/modules/libphp5.so: undefined symbol: ap_unixd_config
Can anybody tell me how to fix this, as I tried every possible solution by googling it but in vain?
Some newer PHP versions may not be compatible with Apache2.2. This error occurs because the function ap_unixd_config is in Apache2.2 still called unixd_config.
Try to use Apache2.4 if you need to use this PHP version, otherwise you can use an older version of PHP.
This also happens on Arch Linux when one doesn't upgrade Apache 2.2 to Apache 2.4. So if you are using Arch Linux you need to downgrade php-apache package to the version that works for you. php-apache-5.5.8-1 is still OK, whereas 5.5.11-1 is not.
On RedHat Apache2 and PHP installation is done by issuing the following commands (as root):
yum install httpd httpd-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd start
That's all. (I'm following this tutorial.) You may add or remove some php extensions to or from the list of packages to be installed if so desired.

Enabling PostgreSQL support in PHP on Mac OS X

I'm having a terribly difficult time getting the command "pg_connect()" to work properly on my Mac. I'm currently writing a PHP script (to be executed from console) to read a PostgreSQL database and email a report.
I've gone into my php.ini file and added
extension=pgsql.so
But, I'm met with the following error.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so, 9): image not found in Unknown on line 0
PHP Fatal error: Call to undefined function pg_connect() in... (blah file here)
When running phpinfo(), I see nothing about PostgreSQL, so what is my issue here?
The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:
Find your version of PHP: php -v.
Download the version of PHP that matches yours: curl -O http://us.php.net/distributions/php-5.3.3.tar.gz. (This example downloads PHP 5.3.3 but this must match your version)
Extract the archive you downloaded: tar -xzvf php-5.3.3.tar.gz
Change to the PostgreSQL's extension directory: cd php-5.3.3/ext/pgsql/
Type phpize.
Type ./configure.
Type make.
Type sudo make install.
Add the extension to you php.ini file by adding extension=pgsql.so. (You may already have done this)
Restart Apache.
Update for OS X Mountain Lion
Apple has removed autoconf from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:
Type /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)".
Type sudo chown -R $USER /usr/local/Cellar.
Type brew update.
Type brew install autoconf.
That should install autoconf and allow you to install the module using the instructions above.
If you use home brew, you can solve this with a command as simple as:
brew install php55-pdo-pgsql
for other php version, search with:
brew search pgsql
This worked for me with OSX 10.9.4 «Mavericks»
Install sources
Download the PHP source code. Unlike on Mountain Lion, you don’t get any headers preinstalled to link against so need to put it in /usr/include/php. Mavericks ships with PHP 5.4.17, but the latest 5.4.x source from php.net should do:
tar -jxvf php-5.4.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.4.20 /usr/include/php
Configure PHP
cd /usr/include/php
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
Building a module
I needed the pdo_pgsql module - the same pattern should apply to just about any module assuming you have the necessary dependencies installed:
cd ext/pdo_pgsql
In my case I had the following error:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. ERROR:
`phpize' failed
So I had to use this command:
brew install autoconf
Then:
phpize
After that I tried to do:
./configure
but I had the next problem:
checking for pg_config... not found configure: error: Cannot find
libpq-fe.h. Please specify correct PostgreSQL installation path
So the solution was to specify correct PostgreSQL installation path:
./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3/
make
sudo make install
That copies pdo_pgsql.so to /usr/lib/php/extensions/no-debug-non-zts-20100525.
Then simply add
extension=pdo_pgsql.so to /etc/php.ini
Run php -m to confirm everything went to plan.
For those who installed php7/ngix/postgres with homebrew
You can install the PostgreSQL module with:
brew install php70-pdo-pgsql
After that, you have to restart the php service:
brew services restart php70
OS X El Capitan users can simply upgrade their version of PHP 5.6. This is a one liner that will do that.
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
For php56 via brew:
brew install php56-pdo-pgsql
PostgreSQL by default is installed in a unusual place on MAC OS X:
/Library/PostgreSQL/9.3
Given the location above you can type this:
./configure --with-pgsql=/Library/PostgreSQL/9.3
I killed the whole day trying to make it work on El Capitan after I made an upgrade yesterday and it turned out that I forgot to modify httpd.conf and change the path from the default php module (version 5.5.27) to the one I installed (version 5.6.14). This should be done in httpd.conf by modifying your default LoadModule php5_module path to LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so.
Just decided to leave it here as the potential solution for those who upgrade their OS or just the PHP version and face the same problem.
For those of you having openssl error while make here is the solution
OSX uses openssl 0.98 while installer is searching for 1.0.0
refer this link for instructions
psycopg2 installation error - Library not loaded: libssl.dylib
I downloaded PostgreSQL for Mac, and used the stack builder after installation to standup the entire EnterpriseDB Apache/PHP stack end-to-end. I mention this as a possible time saving option, probably not ideal for all situations. Should work OK if the apache and postgres shipped with Mac OS X were never started.
To keep existing apache hosted applications (i.e. pre-PostgreSQL install legacy) stable, I would just install the newer EnterpriseDB apache on port 81 (stackbuilder will prompt for new port if legacy apache instance is already running). Then, use mod_proxy in httpd.conf for the apache running on port 80 to provide seamless user experience to applications hosted on PostgreSQL.

Categories