Can't load installed PHP version in Apache (Homebrew OS X) - php

Ok there was question like that but situation was different - I want to use build - in OS-X Apache (2.4) and PHP installed by Homebrew (5.6).
So I put this is httpd.conf
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
And when i restart Apache I get this
httpd: Syntax error on line 118 of /usr/local/etc/apache2/2.2/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: _ap_unixd_config\n Referenced from: /usr/local/opt/php56/libexec/apache2/libphp5.so\n Expected in: /usr/local/Cellar/httpd22/2.2.29/bin/httpd\n in /usr/local/opt/php56/libexec/apache2/libphp5.so
Also First I have installed apache2.2 by homebrew as well. But I decided to remove it and used build-in one. But despite that I removed this in homebrew it is still there. So I have two apache and I am not really sure how to remove 2.2 version.
Can you please help me with these? I tried everything my knowledge allows me to do, so please let me seek yours

If apache can't find libphp5.so there is no libphp5.so on given path.
uninstall php56: brew uninstall php56
install php56 again with Apache option: brew install php56 --with-apache
At the end of installation you can look at summary of installation (last line of terminal output) to find out where libphp5.so is installed (im my case in /usr/local/Cellar/php56/5.6.32_8).
Now you should find libphp5.so in /usr/local/Cellar/php56/5.6.32_8/libexec/apache2

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.

Two versions of php in El Capitan. How do I get rid of one or upgrade the other?

In terminal,
php -v
gives
PHP 5.3.29 (cli) (built: Sep 28 2015 06:33:13)
(with imagick installed) but, in the browser (using apache)
phpinfo();
gives
PHP Version 5.5.27
(with no imagick installed) How do I resolve this?
I don't want to mess about with php.ini and httpd.conf when I'm not entirely sure what I'm doing!
Solved it. I entered
locate libphp5.so
into terminal to find paths to the php installations. This outputted
/usr/libexec/apache2/libphp5.so
/usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
I then edited the apache configuration file
sudo nano /private/etc/apache2/httpd.conf
and changed
LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module /usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
NOTE : This line will be different for your local installation, copy the value outputted from the locate command above
I then restarted apache with:
sudo apachectl graceful
Credit to this solution for the command to find the php installations
This may be a help to you : Upgrade to PHP 5.4 on MAC and remove version 5.3.10
I would suggest that you work in a virtual setup instead.
like Vagrant: https://www.vagrantup.com/
Also take a look at Homestead: http://laravel.com/docs/4.2/homestead
"Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.
"
It will also allow you to keep your configuration if you change machine and/or operating system.

OS X 10.10 - apache will not run PHP from homebrew

I have installed php55 with homebrew to get postgresql support and linked the php module in apache.
LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
Still my phpinfo() - shows PHP 5.5.20 (the built in OS X). But from terminal I get PHP 5.5.26.
What can I do to fix this and force apache to use PHP 5.5.26?
I solved this. I solved this with removing PHP55 (brew uninstall php55 and related php pdo_psql) and reinstalling (brew install php55 --with-postgresql) since I needed postgresql support. I then made sure apache was stopped and started it again. I needed to edit the php.ini file that is now at
/usr/local/etc/php/5.5/php.ini
Everything seems fine now and using the new PHP55 I installed with homebrew.

Installing PHP on Linux: Cannot load /etc/apache2/modules/libphp5.so into server

I've installed PHP with yum install php, after that I've added the following lines in httpd.conf
LoadModule php5_module modules/libphp5.so
....
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
And after that I've copied libphp5.so to /var/apache2/modules. Then I said /etc/apache2/bin/apachectl -k stop and got the following error.
httpd: Syntax error on line 57 of /etc/apache2/conf/httpd.conf: Cannot
load /etc/apache2/modules/libphp5.so into server:
/etc/apache2/modules/libphp5.so: undefined symbol: ap_unixd_config
Installed PHP version is 5.4.41. OS is CentOS Linux release 7.1.1503.
Can someone tell me where the problem is?
UPD Apache version is 2.4.6 (64-bit), line 57 of httpd.conf is LoadModule php5_module modules/libphp5.so
What's odd about this is that you installed PHP using yum and then went to add php.so to Apache. The RPM should do that for you (that's the whole idea behind package managers). In CentOS 7 the .so file is loaded in /etc/httpd/conf.modules.d (you should have a file called something like 10-php.conf). There should also be a /etc/httpd/conf.d/php.conf file where your FilesMatch directive is added. If you are defining these twice you could be causing issues.
I would also suggest that you use a later version of PHP than 5.4 (this version will go into End Of Life when PHP 7.0 is released later this year). If you're not using the Remi repo then I would set that up and you can get 5.5 or 5.6. I am using this myself and have not any of the issues you mention. It could also be that the version of PHP you installed is not compiled for CentOS 7 (this issue is unique to Apache 2.4). Remi does have a CentOS 7 repo.

different version php on command line and in apache

I am using mac 10.8 and I have installed php 5.5. At command line php -v show version 5.5. but when I starts mac's apache server with phpinfo(), it show version 5.4.
Can anyone please help me how to make apache to use version 5.5
Thanks
find out the conf/httpd.conf and conf.d/*.conf
find the tag like this: LoadModule php5_module modules/libphp5.so
make the change to correct php installation folder like this:
LoadModule php5_module /usr/local/Cellar/php54/5.4.8/libexec/apache2/libphp5.so
This will change your php model (php version) in Apache
Search on your local desk: find / -name "libphp5.so"
Regarding the correct so file: libphp5.so not being created after compiling and prefix directory not created
[update]
http://www.howtoforge.com/centos-5.6-php53-common-conflicts-with-php-common
1) update yum to include latest php
2)
For 64bit systems, you can find the correct packages here: http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/
For 32bit systems, the correct packages are here: http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/
3)
(replace to the correct URL and file name which you want to have, check it from step "2)")
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-11.ius.el5.noarch.rpm
4) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
5) yum install yum-plugin-replace
6)
You can now replace your PHP old version packages with the PHP new version packages from IUS like this:
yum replace php --replace-with php55w
You can search for further php55w packages like this:
yum search php53u
If you uncommented the line LoadModule php5_module /usr/local/php5/libphp5.so in httpd.conf comment it again, then add the line export PATH=~/bin:/usr/local/php5/bin:$PATH in .bash_profile
This did the trick for me. Note: i have installed php5.5.5 via liip on OS X Mavericks

Categories