Recently installed php71 on my local test environment.

I have an index.php file with phpinfo() in the web root directory.

When I LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so, index.php renders correctly, reporting the expected php version.

Alternatively, LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so gives a 403 forbidden message.

This is the same for all of my local web root directories. They render correctly in their entirety when using php5.6, and give me a 403 error when using php7.1.

Do php versions interpret httpd-vhosts.conf differently?

  • I think there's an old saying "If it ain't broke, don't fix it". So if PHP 5 works well, why upgrade to PHP 7 if its not necessary? Personally, I'd factor in why a newer version of something is mandatory before accepting it because sometimes newer things break down far easier than the old. That's my 2-cents Feb 9 '18 at 6:16
  • I appreciate the comment, but my new work project is in 7.1. I always like to have a project working in a local environment before I start branching a repo.
    – pcgben
    Feb 9 '18 at 12:15

Php7.1 requires the following addition to httpd.conf

SetHandler application/x-httpd-php

When reverting back to php5.6, that line must be commented out, or again, the php code will not be interpreted.

  • 1
    This isn't specific to PHP 7.1, this could apply to any version of PHP and is more likely to do with the way your server is configured. Your PHP 5.6 install was perhaps using a different handler that needed to be either removed or overridden. Adding the SetHandler directive is probably overriding the PHP 5.6 handler. (?)
    – MrWhite
    Feb 9 '18 at 17:32
  • Thank you -I really don't understand the reason behind the solution. I changed things one at a time, and this consistently solved the issue. What I don't understand is why it was 403'ing and not simply failing to render. Where else can the SetHandler directive be set?
    – pcgben
    Feb 9 '18 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.