1

I have the opposite question from Why is the PHP version different in phpinfo() and CLI? My question is different from that one because I'm getting the expected PHP for the CLI and the wrong one for my local web server. Also, the solution offered there (changing the the path to the "LoadModule" in apache2/httpd.conf) does not work for me because the PHP version installed by brew has no analogous .so file to go in LoadModule.

I was running PHP 5.5 on Mac El Capitan. I am trying to run Craft CMS on my local machine, which requires mcrypt, which is installed with PHP 5.6 and above.

Using brew, I installed PHP 5.6. But when I run phpinfo(); in my Craft folder I am still on PHP 5.5.

If I go to the command line and say which php, I get:

php is /usr/local/bin/php
php is /usr/bin/php
php is /usr/local/bin/php

Then, /usr/local/bin/php -v gives me: PHP 5.6.30 (cli) (built: Mar 11 2017 09:56:18)

and /usr/bin/php -v gives me:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so, 9): image not found in Unknown on line 0
PHP 5.5.36 (cli) (built: May 29 2016 01:07:06)

The only place I know PHP is called for the server is in etc/apache2/httpd.conf, where it's called by uncommenting LoadModule php5_module libexec/apache2/libphp5.so.

The brew PHP is in /usr/local/Cellar/php56, but there is no .so file there.

I also have homebrew.mxcl.php56.plistin ~/Library/LaunchAgents, copied from the brew install.

The php.ini file is still the same one from the etc folder.

What should I do to load the newer PHP 5.6 instead of the standard PHP 5.5?

David Rhoden
  • 163
  • 1
  • 1
  • 6
  • Your problem is no different than the question claim is the same but different. Your command line PHP has utterly no impact on your Apache PHP module. If you want to use and install a new PHP module, you need to edit the line `LoadModule php5_module libexec/apache2/libphp5.so` to point to the exact location of the other PHP module you want to load. The path is `libexec/apache2/libphp5.so`. But at the end of the day you are making your life harder by kludging this stuff together the way you are doing. The best way to LAMP develop on a Mac is by using [MAMP](https://www.mamp.info/). – Giacomo1968 May 03 '17 at 03:30
  • And you should [check out this similar question as well](https://superuser.com/a/971895/167207). But you also say, “I am trying to run Craft CMS on my local machine, which requires mcrypt, which is installed with PHP 5.6 and above.” Mcrypt is a PHP extension that is not really tied to PHP 5.6. [Read up more on this here](http://stackoverflow.com/questions/16830405/laravel-requires-the-mcrypt-php-extension). In general your approach to creating a LAMP stack on a Mac is inherently going to give you a massive headache. Just go with MAMP instead. – Giacomo1968 May 03 '17 at 03:33
  • Well, where is the location of the other PHP module I want to load? As I sai, there's no .so file in the PHP that brew installed. – David Rhoden May 03 '17 at 03:51
  • I was going to ask if I should go back to using MAMP as I used to do, but I would like an answer to my original question as well. I don't think it's a duplicate of the one I said it was the opposite of. That was a good question with good answers, but my situation is different. Had it answered my question, I wouldn't have asked it. I really need to be shown the exact correct path, and I'd like to know why putting the .plist file in LaunchAgents doesn't launch PHP5.6. – David Rhoden May 03 '17 at 03:55
  • I wasn't able to successfully upgrade using brew. I was able to successfully upgrade by downloading from this source: `curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6` – David Rhoden May 03 '17 at 12:20
  • “I was going to ask if I should go back to using MAMP as I used to do…” Utterly no idea why you’re avoiding MAMP in a cavelike this. I used to compile from source (!!!) in Mac OS X 10.6 back in the day to get a local development environment setup. MAMP changed my life and I code and deploy regularly on macOS with MAMP to Linux servers of all types without issue. – Giacomo1968 May 03 '17 at 14:32

0 Answers0