0

I'm on a Mac (OS Sierra, 10.12.6). If I run php -v, then it tells me, that I'm running version 5.6.30. And if I run which php then it gives me this path: /usr/bin/php.

I would like to run PHP7.1, - and I would like to install it using Homebrew. But before I do so, I thought it would be wise, to ensure that all old stuff, that can be removed - is removed.

I'm not running a local server or anything. But I still took a look inside this file: /private/etc/apache2/httpd.conf, - then I can see that this line is commented out:

#LoadModule php5_module libexec/apache2/libphp5.so

And I can't imagine what other programs would have PHP5 as a dependency.

I know that I can run PHP5 and PHP7 in parallel. And the answer from this post stated, that as long as your /usr/local/bin/ came before /usr/bin in my `$PATH$, then the Homebrew-PHP would be used. But it just seems a bit hacky, - to just 'put PHP7 in front of PHP5' and disregard any potential collision further down the line.

So to sum up... Can I delete my PHP5-installation? Or is it like with Python-versions, that there's a native version (2.7.x) that shouldn't be tinkered with, - and then you can install your own version somewhere else?

And if I can simply remove PHP5, - then how do I do it (I can't find that anywhere)? I haven't installed PHP5 myself, - and it's not installed with Brew. I have PhpStorm installed, - so it may have come with that.

Zeth
  • 2,273
  • 4
  • 43
  • 91
  • You should have only one active PHP on your server – Peon Aug 13 '17 at 09:56
  • 1
    Why do you have php installed _at all_ if you are not using it? PHP is nearly exclusively used for web tasks, though other things would be possible too. Python is used as a base for many local (client side) applications, so that is a completely different story. – arkascha Aug 13 '17 at 10:00
  • _"I would like to run PHP7.1"_ - For what exactly? – M. Eriksson Aug 13 '17 at 10:04
  • DainisAbols: It's not on a server. It's on my own machine. arkascha: I don't know why I have it installed. I think it got installed with PhpStorm or something. I haven't used it previously (locally) - I've just written it locally and uploaded all PHP-files to a server. MagnusEriksson: I didn't include it in the question, cause I thought it didn't matter. But I'm making a Laravel-application and developing it locally. So I would like to install Composer, Laravel, Valet, Xdebug and all that jazz... :-) – Zeth Aug 13 '17 at 10:15

1 Answers1

0

I solved it by adding it as an alias, by writing brew info php71, finding it in the Cellar-folder, and then linking to it by adding this:

alias php='/usr/local/Cellar/php71/7.1.10_21/bin/php'

The answer was inspired by Xeoncross's answer from this article.

My guess is that PHP v. 5.6 came with PhpStorm. And I'm not sure if it will give problems somewhere, to change the php-command. If I stumble across any of that, then I'll update this post.

Zeth
  • 2,273
  • 4
  • 43
  • 91