1

I recently reinstalled Apache and now my PHP code is shown directly instead of being ran. For example, if I go to example.com/info.php, all I see is:

<?php phpinfo(); ?>

I double checked PHP wasn't uninstalled. Is there some configuration setting somewhere I'm missing?

Solution (question is not duplicate)

This problem was because after the new install of Apache, the modules were not configured correctly. Something about thread vs events. Anywho, run these commands:

a2dismod mpm_event
a2enmod mpm_prefork
systemctl restart apache2.service

Now my php works perfectly

Oren Bell
  • 460
  • 1
  • 5
  • 13

1 Answers1

1

check the apache configuration:

ensure that in your httpd.conf you have the line LoadModule php5_module modules/libphp5.so or LoadModule php7_module modules/libphp7.so

if you're using php7 check that in apache configuration there is something similar to

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

check that starting apache you don't have error messages (some broken path or some mistype in configuration or similar)

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

Zainul Abideen
  • 1,829
  • 15
  • 37