1

I've recently had difficulties with Apache not processing PHP files on my Mac after upgrading to macOS Sierra. Original post about it is here.

The way in which I "fixed" this problem was to add the following to /etc/apache2/httpd.conf

AddType application/x-httpd-php .php

I then restarted Apache sudo apachectl restart and my PHP scripts were processed.

However, when I run a phpinfo() script it's saying PHP Version 5.6.24

When I run PHP from a command line, it's reporting PHP 7.0.10 (which is what I expect and want).

It gets stranger because I don't know where PHP 5.6.24 even exists on my system. If I run

which php

It gives:

/usr/local/php5/bin/php

But examining this further, that appears to be a symbolic link to PHP 7:

$ cd /usr/local
$ ls -l
lrwxr-xr-x 1 root  wheel 38 14 Sep 11:18 php5 -> /usr/local/php5-7.0.10-20160831-102733

Executing PHP directly from /usr/local/php5-7.0.10-20160831-102733 also reports PHP 7:

$ pwd
/usr/local/php5-7.0.10-20160831-102733/bin
$ ./php -v
PHP 7.0.10 

How do I get Apache to use PHP 7.x, and more importantly, where is PHP 5.x on my system that it's running?

Andy
  • 163
  • 1
  • 1
  • 4
  • 1
    The version of PHP you run from the command line has 100% nothing to do with the PHP module Apache is running when it starts up. This question has been asked before. And the long story short is that you need to adjust your Apache’s config file to point to and use `libphp5.so` (the PHP 5 module Apache would use) instead of `libphp7.so` and you should be good to go. – Giacomo1968 Oct 03 '16 at 14:56

1 Answers1

-2

php can be built in various variants. There is at least a command line variant, a cgi variant, a fastcgi variant and an apache module.

You need to build a php 7 apache module, then reconfigure apache to use it.

http://php.net/manual/en/install.unix.apache2.php

plugwash
  • 5,994
  • 2
  • 18
  • 25
  • "You need to build a php 7 apache module" - How do you do this specifically? "You then reconfigure apache to use it." - How is this done? – Ramhound Oct 03 '16 at 14:50
  • If you are building both apache and php from source then the details are at the link I gave. If you use apache from some sort of package then you will have to figure out how to install the file needed to build modules within that specific packaging system. – plugwash Oct 03 '16 at 15:03