PHP and Apache or other web server


I have successfully installed and configured Apache web server on Haiku and would like to use PHP with this webserver.

I have installed the PHP8 package, however now the next step is : how to configure apache in order to use PHP8 on Haiku ?

Thanks !

This link explains a little about Apache and PHP:

Mmm, I already know about Apache and PHP. My question is more : is PHP working with Apache on Haiku ? And if so how to ?

The link provided seems to be an old package with a download page not available.

I’ve installed Apache via HaikuDepot :

And then PHP8 :

If I remember correctly on Linux, in addition to Apache and PHP, you need to install libapache2-mod-php.
Without this module, the PHP page will be displayed as raw text which is the case today in Haiku.

So if anyone has successfully run PHP with Apache (or another webserver) on latest version of Haiku, this help would be appreciate.

Maybe you can make it work, but i doubt anyone has tried since Haiku is not a server operating system, and as such this is normally not done.

Ok understood, for the moment yes my aim would be to have Haiku as a testing environment for Apache/PHP but not a production one :slight_smile:

Maybe the documentation can help you

Now that containerization is becoming a standard among large corporations, Apache or MySQL (maybe maria db) can be made available as open source.

Apache/MySQL/MariaDB are already opensource projets.

lighttp server + php8, however it requires a few manual configuration :


Server launch :
/bin/lighttpd -f /system/settings/lighttpd/lighttpd.conf


Install php8 + create the directory “/boot/home/www” with your HTML/PHP pages

Then edit :

  • file /boot/system/settings/lighttpd/conf.d/fastcgi.conf :
server.modules += ( "mod_fastcgi" )

fastcgi.server = ( ".php" =>
     "socket" => "/tmp/php.socket",
     "bin-path" => "/bin/php-cgi",
     "bin-environment" => (
      "PHP_FCGI_CHILDREN" => "16",
      "PHP_FCGI_MAX_REQUESTS" => "10000"
     "min-procs" => 1,
     "max-procs" => 1,
     "idle-timeout" => 20    
  • file /boot/system/settings/lighttpd/modules.conf :
#/ FastCGI (mod_fastcgi)
include "conf.d/fastcgi.conf"
  • file /boot/system/settings/lighttpd/lighttpd.conf :
var.log_root    = "/boot/system/var/log/lighttpd"
var.server_root = "/boot/home/www"
var.state_dir   = "/boot/system/var/run"
var.home_dir    = "/var/lib/lighttpd"
var.conf_dir    = "/boot/system/settings/lighttpd"

server.document-root = server_root + "/"

Thanks a lot. This is great information, like you said not for running Haiku as a real webserver but for using Haiku for web development.

It is also worth noting that PHP has a built-in server, which is very useful for testing purposes:

$ php -S

(or whatever address you want to listen on.)

1 Like

Ah nice also ! I wasn’t aware of the PHP built-in server

Same with Python:

$ python3 -m http.server --cgi 
Serving HTTP on port 8000 ( ...


$ python3 -m http.server --cgi -b 8080
Serving HTTP on port 8080 ( ...
1 Like

Right, but the Python built-in server doesn’t support PHP, while the PHP built-in server obviously does.

1 Like

It does, but one has to add the --cgi option to the command lines above (I’ve updated the examples).

The scripts should be placed in the cgi-directories (defaults to [‘/cgi-bin’, ‘/htbin’]), and made executable (via chmod +x …).

One can run PHP scripts like:

<? phpinfo(); ?>

Or Python ones:

#!/usr/bin/env python3
print("Content-Type: text/html\n")
print("<!doctype html><title>Hello</title><h2>Hello World!</h2>")

If OP is interested only in PHP, then of course the PHP built-in server is the first choice, Python is just another alternative to be aware of.

That shebang is wrong, Haiku has no /usr, so either it is broken or uneccesary.

If php is in the default path #!php should work.

Linux-style shebangs with /usr/bin/ in them are supported on Haiku, the /usr/ part will just be ignored.

Why are we breaking shebangs? That‘s not really supporting them. But alright, if they are misinterpreted on purpose I was wrong in my message.

There is no specification anywhere for how they should work. The Linux implementation is bad (there is an arbitrary limit on the line length, you can have only one argument to the command, and for some reason the executables are not searched in the PATH and you have to give an absolute path). But that’s just how Linux does it, there is no reason to implement something as broken as they did.

The Haiku implementation tries the path you give first, and if the executable is not found there, tries again by looking up the executable name in the PATH. You can also path any number of arguments and there’s no limit to the line length.