Home | News | Download | Packages | Forum | Wiki | Github

[SOLVED] PHP not running in Apache


I installed apache, php and php-apache with XBPS, started Apache with runit.

Apache version is 2.4.25 and PHP is 7.1.7

I made a test.php sample file in the root directory. Inside the file the content is <?php phpinfo(); ?> and when I visit the file with the browser in http://localhost/test.php I only get a blank page.

I inspect the blank page and see that the PHP code is commented out in HTML, like this:

<!--- <?php phpinfo(); ?> -->

No relevant errors in /var/log/httpd/error_log

# sv status apache shows Apache is running, but

# apachectl status returns this message:

Object not found!

The requested URL was not found on this server. If you entered the URL
manually please check your spelling and try again.

If you think this is a server error, please contact the [1]webmaster.

Error 404

Apache/2.4.25 (Unix)


  1. mailto:you@example.com
  2. http://localhost/

But I can access http://localhost/ in my browser. It shows a simple index.

ps ax | grep runsvdir returns nothing relevant.

I’m using the kernel 4.11.11_1 in a 32-bit install.

I’ve read that a PHP7 module needs to be implemented, but I don’t know how would I do it in this case.

(Stefan Mühlinghaus) #2

These are the steps to get the PHP module running in Apache:

  1. Disable the mpm_event_module and enable the mpm_prefork_module in /etc/apache/httpd.conf so that it looks like this:

#LoadModule mpm_event_module /usr/libexec/httpd/mod_mpm_event.so
LoadModule mpm_prefork_module /usr/libexec/httpd/mod_mpm_prefork.so

  1. At the end of the other LoadModule directives insert one to load the PHP module:

LoadModule php7_module /usr/libexec/httpd/modules/libphp7.so

  1. At the end of the file include the PHP configuration:

Include /etc/apache/extra/php7_module.conf

  1. Restart Apache:

sv restart /var/service/apache

Now PHP should be working in Apache.


That did it. Thank you @jazzman.

(Erin) #4

I would like to make a comment. Network security is an art. Based on this and other posts you have made, please be very careful and ensure that your network is firewalled from the external world or, if you want to expose your Apache instance to the world, you put it in a DMZ and have nothing valuable on the machine. I feel everyone would encourage you to learn and experiment. Just be careful.


Thank you for the advice, but there’s no need for tight security. This is not intended for a production environment, just for tinkering in my machine.