1

This question already has an answer here:

NOTE: This is not a duplicate of, nor is the answer here: Apache is not interpreting .PHP files


On my local Apache webserver, and I have PHP 5.6 and 7.0 installed. When I run 7.0 the scripts are not executed (just raw text is displayed), but when I switch to PHP 5.6 everything is fine.

I've checked my httpd.conf when running 7.0, and it's correct:

LoadModule php7_module /usr/local/opt/php70/libexec/apache2/libphp7.so

Typing php --ini in terminal produces the following:

Configuration File (php.ini) Path: /usr/local/etc/php/7.0
Loaded Configuration File:         /usr/local/etc/php/7.0/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.0/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.0/conf.d/ext-mcrypt.ini

Which looks correct.

Typing apachectl -v produces:

Server version: Apache/2.4.18 (Unix)
Server built:   Feb 20 2016 20:03:19

I feel like it's an issue with my Apache config.

marked as duplicate by Iain, Ward, mdpc, MadHatter, womble Jul 8 '16 at 6:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @Iain Please read the entire post, not just the subject line. It's a different issue. – Django Reinhardt Jun 29 '16 at 10:47
  • It is the same issue, it also has the same solution. – Iain Jun 29 '16 at 11:15
  • @Iain Did you link to the wrong question by mistake? There is no accepted solution on that page, and there is no unaccepted solution on that page that solves the issue I had, either. – Django Reinhardt Jun 29 '16 at 14:38
0

Aha! It looks like httpd.conf was missing an important line:

AddType application/x-httpd-php .php

For some reason it didn't cause problems with PHP 5.6, but it not being there caused problems with PHP 7.0. Strange.

  • If you had used search (above right) you would find that this is a duplicate multiple times over. – Iain Jun 29 '16 at 10:34
  • @Iain I did that, there is not a duplicate of this issue (earlier version of PHP executing scripts fine, current version not). – Django Reinhardt Jun 29 '16 at 10:51

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