Installing httpd and php in Mac OS 12 - php

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

Related

Installing PHP 7.4 on macOS Sierra without brew?

I am unable to find any info on installing PHP 7.4, all the info seems to go untill 7.3 but that has not been helpful.
What I have done so far is execute:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.4
And this is the message I got:
It doesn't seem to install. How can I solve this problem?
If you check the script https://php-osx.liip.ch/install.sh you can see it only support 7.3
Yes, you can install and upgrade to latest php version on mac without homebrew.
For me I use MacPorts a package manager for MacOS which is similar to HomeBrew but more stable.
Example to upgrade to php74:
sudo port install php74
Install the extensions you need
sudo port install php74-cgi php74-gd php74-curl php74-intl php74-iconv php74-gettext php74-mbstring php74-imap php74-mcrypt php74-xmlrpc php74-mysql php74-openssl php74-sockets php74-zip php74-tidy php74-opcache php74-xsl php74-sqlite
Select php74 as the active PHP version. With this command you can have multiple php version and quickly switch from one to the other.
sudo port select php php74
Check which PHP binary is used (should return /opt/local/bin/php). Perhaps you may need to restart you terminal.
which php
Check the version (should return “PHP 7.4.XX (cli)…”)
php --version
Also, If you use XAMPP ensure to restart Apache Web server.
(Article Reference)

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

Ubuntu 12.04 PHP 5.5 and apache2 2.4

I'm on Ubuntu 12.04 64 bit, I decided to upgrade to PHP 5.5 from 5.3 and apache2 2.2 to 2.4. I did something similar to Installing apache 2.4 and php 5.5 on ubuntu 12.04. Long story short something's broken and it's not working correctly so I want to go back to PHP 5.3 and apache2 2.2.
Is it just a case of uninstalling PHP and Apache, removing the sources I added, do a package update and then reinstalling PHP and Apache using apt? I just want to go back to a version of PHP and Apache that work correctly and are supported by 12.04.
Thanks.
Remove the files in /etc/apt/sources.list.d/ that matches the ppa names you added. You should find one like ondrej
Run then sudo apt-get update && sudo apt-get install php5 apache2 and you should have all back working
I've used ondrej ppa too (There are apache 2.4 and mysql 5.6 too from the same author which works really well for me, https://launchpad.net/~ondrej)

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 and Terminal runs 2 different php builds, on Mac OS 10.8

Since Mac OS 10.8 had an old PHP version I had to install a never version of PHP. So I just compile PHP 5.4.13. Then I do a php -v on the terminal and it shows me that the new php version is running. But When I do a phpinfo from the browser it shows me the old PHP version which is PHP 5.3.x. This is even after creating a soft link to the new php build,
/opt/local/lib/php(old one) -> /usr/bin/php(new one)
Any ideas how to fix this issue?
I just ran into the same issue, wanting to try Laravel which requires mcrypt.
In a nutshell, I had been using the built-in PHP 5.3.26 that came with Mountain Lion, then some months later after I'd gotten more familiar with homebrew, I used it to install a newer version of PHP.
brew update
brew upgrade
brew install php53 php53-mcrypt ...
I put
<?php phpinfo();
into ~/Sites/info.php then went to localhost/info.php to see my Apache+PHP config. On the page, I saw this, under Loaded Configuration File:
/private/etc/php.ini
Then in Termninal, I ran this:
php -i | grep ini
which showed this output
Loaded Configuration File => /usr/local/etc/php/5.3/php.ini
Plus even more configs loaded as well ...
Additional .ini files parsed => /usr/local/etc/php/5.3/conf.d/ext-mcrypt.ini,
/usr/local/etc/php/5.3/conf.d/ext-xdebug.ini,
/usr/local/etc/php/5.3/conf.d/redis.ini
The problem I had was that mcrypt was loading in the php cli version, but my Laravel test page wouldn't load giving an mcrypt extension not found error [1]
I used a diffmerge tool [2] to compare the original Apple php.ini in /private/etc/ to the one homebrew installed in /usr/local/etc/php/5.3/ and found there to be significant differences! So check carefully before trying this:
What I did next was to backup
sudo mv /private/etc/php.ini /private/etc/php.ini.apple
Then symlink the php.ini to homebrew's instead
ln -s /usr/local/etc/php/5.3/php.ini /private/etc/php.ini
Finally after reloading Apache
sudo apachectl restart
And mcrypt loaded, and now they're using a single config.
If you have another app on your localhost that breaks with the new config, just remove the symlink, and change it to the .apple version and restart Apache to revert back.
Laravel requires the Mcrypt PHP extension
https://sourcegear.com/diffmerge/
This might be a good reference:
how do i install php 5.4 on Mac OS X Lion?
There are some detailed instructions on upgrading PHP to 5.4, and also notes on how MacPorts can make it pretty painless.
I'm running OS X 10.9. I updated PHP to v5.5.8 and found that Apache was correctly running the new version but the terminal was still running the old one. After hunting around for a solution for a while, I eventually thought, "I'll give it a restart."
Bingo! Terminal and Apache are running the same version of PHP.

Categories