Php /

Install PHP for OpenHTTPd

(redirected from Openbsd.Php)


$ doas pkg_add php-8.0.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