So I built a embedded apache web server using buildroot, and it's is running fine except the fact that it doesn't run php code. I can run .php files in the command line of the system but when I open those .php files in a browser it doesn't run the php code, it simply ignores all php code and interprets it like if it was html.

I looked in the /etc/apache2/httpd.conf file and it has a line loading the php module:

LoadModule php7_module     modules/libphp7.so

Does anyone knows how to make php run?

I will leave, just in case, information about some directories and files that might be relevant:


  • apache2/

  • php-fpm.conf

  • php-fpm.d/

  • php.ini


  • extra/

  • httpd.conf.bak

  • mime.types

  • httpd.conf

  • magic

  • original/


  • (empty)



In addition to loading the module (which your httpd.conf file shows it is doing based on the content of your question) you also need to use a SetHandler directive for *.php or other appropriate extensions.

Something like this should work, just put it right after the LoadModule statement.

<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    SetHandler application/x-httpd-php

What this above statement does it is tells Apache how to deal with files with certain extensions. The .+\.ph(p[3457]?|t|tml)$ is a regular expression (regex) that matches several different endings for the file (the $ indicates end of the string) - so files ending in .php, .php3, .php4, etc. will all get processed by the Apache server and PHP module before being sent to the browser.

Don't forget to restart the httpd service.

If it still doesn't work, check the paths referencing the module to load and make sure the libphp7.so is in the right location to be loaded.

| improve this answer | |
  • Thanks a lot, it worked. Can you just explain me what the <FilesMatch ".....$"> statement does? I tried with and without it and it worked both ways. – IncognitoCoder Dec 21 '17 at 14:25
  • @M_Luis - I've edited the answer to include more info on it – ivanivan Dec 21 '17 at 15:36

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.