OSX - installing Apache/PHP stack trough Homebrew fails - php

I'm stuck. I am trying to install Apache stack on OSX 10.10.3 and i can not get PHP56 to work with Apache. I am getting
httpd: Syntax error on line 171 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/Cellar/php56/5.6.10/libexec/apache2/libphp5.so into server: dlopen(/usr/local/Cellar/php56/5.6.10/libexec/apache2/libphp5.so, 10): Library not loaded: /usr/local/opt/apr-util/libexec/lib/libaprutil-1.0.dylib\n Referenced from: /usr/local/Cellar/php56/5.6.10/libexec/apache2/libphp5.so\n Reason: Incompatible library version: libphp5.so requires version 6.0.0 or later, but libaprutil-1.0.dylib provides version 4.0.0
when running
sudo bash -x /usr/sbin/apachectl -k restart

I fixed it but I don't know how precisly.
Basically I've reinstalled all PHP packages installed trough brew, and I went back to use Apache 2.4 originally installed on OSX, and not that one from brew.

Related

Apache, PHP 5.6 or 7.0: Library not loaded: openssl/lib/libcrypto.1.0.0.dylib using Homebrew

I am trying to load either PHP 5.6 or PHP 7.0 module in the Apache httpd.conf config file on macOS 10.15 Catalina. But what I receive when starting the Apache server using sudo apachectl start in Terminal is the following error:
httpd: Syntax error on line 187 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so into server: dlopen(/usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so, 10): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib\n Referenced from: /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so\n Reason: image not found
Since PHP versions 5.6, 7.0 and 7.1 have been deprecated and removed from Homebrew, following this guide, I had to use an older deprecated tap and installed both PHP 5.6 and 7.0 by running:
brew tap exolnet/homebrew-deprecated
brew install php#5.6
brew install php#7.0
For the sake of complete information, I have tried both the Apache which comes with macOS and the latest Apache 2.4.43 installed via Homebrew, but this should not make a difference.
So the question is, how can I solve these errors and make PHP 5.6 and 7.0 running on macOS using Homebrew?
The solution is to install an older version of the openssl library. To be more specific, PHP 5.6 and php 7.0 require openssl 1.0.2, which you can install via Homebrew by running the following in Terminal:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8b9d6d688f483a0f33fcfc93d433de501b9c3513/Formula/openssl.rb
brew switch openssl 1.0.2t
However, after running the above, when using PHP 5.6, php 7.0 or php 7.1, another "Library not loaded" error might occur., in particular, this one:
httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so into server: dlopen(/usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so, 10): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib\n Referenced from: /usr/local/opt/php#5.6/lib/httpd/modules/libphp5.so\n Reason: image not found
Here, another older library is required, icu4C in this case. The solution is to run the following:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
brew switch icu4c 64.2
Note for switching to PHP 7.2, PHP 7.3 or PHP 7.4
Since PHP 7.2, PHP 7.3 and PHP 7.4 do not work with the above mentioned older, 64.3, version of the icu4c library, whenever you need to switch to these PHP versions, e.g., by using this easy brew PHP switcher script, you also hav to switch the version of the icu4c library by running this command:
brew switch icu4c 67.1
Resources
OpenSSL 1.0.2m on macOS - Stack Overflow.
homebrew-core/openssl.rb at 75b573845a17aaf3f7c84dc58e97cf5fe39a502b ยท Homebrew/homebrew-core.
node.js - dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac - Stack Overflow.
macOS 10.15 Catalina Apache Setup: Multiple PHP Versions | Official home of Grav CMS.

libfreetype.6.dylib incompatible

I get the following error when I run MNPP, which is a like XAMPP/MAMP but with Nginx instead of Apache.
$ sudo mnpp --php53 --start
-n Starting php-fpm
dyld: Library not loaded: /opt/X11/lib/libfreetype.6.dylib
Referenced from: /usr/X11/lib/libfontconfig.1.dylib
Reason: Incompatible library version: libfontconfig.1.dylib requires version 17.0.0 or later, but libfreetype.6.dylib provides version 14.0.0
/Applications/MNPP/init/php.sh: line 95: 44087 Trace/BPT trap: 5 $php_fpm_BIN $php_opts
failed
Judging from all the SO threads on this topic, I'm pretty sure this is a X11/XQuartz Mac OSX Mavericks issue as it this command works on my previous Mac with 10.7.5.
How do I upgrade my version of libfreetype.6.dylib?
You likely have the DYLD_LIBRARY_PATH environment variable set. Don't do that.

Amazon Linux LAMP with php 5.5

I installed PHP 5.5 on my Amazon Linux VPS via the instructions here. The CLI is working fine.
I also had apache already installed and running via the httpd package. It was running without any issue.
I see that there is no mod_php in the list of available modules. Now when I try to restart httpd I get the error:
httpd: Syntax error on line 222 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/php.conf: Cannot load /etc/httpd/modules/libphp5.so into server: /etc/httpd/modules/libphp5.so: symbol SSLeay_version, version OPENSSL_1.0.1 not defined in file libcrypto.so.10 with link time reference
I've looked up parts of this error, and the general advice seems to be to run
yum update openssl
However, when I run this I just get:
No packages marked for update
When I run install instead of update, I get:
Package 1:openssl-1.0.1e-4.55.amzn1.x86_64 already installed and latest version
Nothing to do
I'm not sure what else to do at this point.
The php55 package in the Amazon Linux YUM repository requires the http24 package, not the http package.

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.

apache + php configuration on mac

Good day.
I have a problem with Apache configuring on my Mac.
I installed apache and php from MacPorts, apache works fine.
When I add line
Include conf/extra/mod_php.conf
and restart apache - here is an error:
httpd: Syntax error on line 119 of /private/etc/apache2/httpd.conf: Cannot load /opt/local/apache2/modules/libphp5.so into server: dlopen(/opt/local/apache2/modules/libphp5.so, 10): Library not loaded: /opt/local/lib/libaprutil-1.0.dylib\n Referenced from: /opt/local/apache2/modules/libphp5.so\n Reason: Incompatible library version: libphp5.so requires version 6.0.0 or later, but libaprutil-1.0.dylib provides version 4.0.0
So, this is my question: what should I do for resolve this problem?
thanks a lot!
Good luck.
Ditch MacPort and install MAMP from this link.
MAMP installer comes with Apache, PHP and MySQL bundled.
Update: There is a better LAMP package available now on OSX called AMPPS.

Categories