Php /

Install PHP for OpenHTTPd

(redirected from Openbsd.Php)

You'll first want to choose the version of PHP you use:

Install PHP7

$ doas pkg_add php%7
$ doas rcctl enable php74_fpm
$ doas rcctl start php74_fpm

Install PHP8

$ doas pkg_add php%8
$ doas rcctl enable php80_fpm
$ doas rcctl start php80_fpm

Then, in /etc/httpd.conf, add the following block:

server "" {
        listen on * port 80
        location "/.well-known/acme-challenge/*" {
                root "/acme"
                request strip 2
        location "*.php" {
                fastcgi socket "/run/php-fpm.sock"
		root "/htdocs/"

Lines 3-7, the location "/.well-known/acme-challenge/*" block, is for acme-client, for requesting new SSL certs.

Lines 8-11, the location "*.php" block, tells the web server to use PHP for any file that ends with a .php file extension.

Line 10 says where the document root is located -- where web files should be placed. By default, openhttpd chroots into /var/www, so if your document root is /htdocs/, then your actual web files need to be placed in /var/www/htdocs/

NOTE: Make sure to replace with your real domain.

To test your installation, create the file /var/www/htdocs/

<?php phpinfo(); ?>

Then, have your web browser visit . If you set everything up correctly, you should see a screen full of PHP installation information.

For SSL, you will want to follow the OpenHTTPD TLS? or relayd guides.


If you run into any PHP configuration errors, check the logs folder in /var/www/logs:

$ less /var/www/logs/access.log
$ less /var/www/logs/error.log


File PathPurpose
/var/www/logs/access.logWeb access logs
/var/www/logs/error.logWeb error logs

Upgrading Notes

If you are upgrading to php8.0 and you have got pmwiki, then make sure that you update your pmwiki, else it will spam your logs and it will be within a minute that you got no space left on /var