Need to migrate your e-mails to a new server? Free and paid versions of our online tool available.
Hero Image

Integrate PHP-FPM with Nginx on OpenBSD 7.5

Integrate PHP-FPM with Nginx on OpenBSD 7.5

Prerequisites

PHP-FPM installed and running. See PHP-FPM install guide.

Socket path: /var/run/php-fpm.sock

Step 1 – Nginx server block

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com/html;
    index index.php index.html;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        include        fastcgi_params;
        fastcgi_pass   unix:/var/run/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    location ~ /\.ht { deny all; }
}

Step 2 – Test

nginx -t && systemctl reload nginx 2>/dev/null || nginx -t && rc-service nginx reload 2>/dev/null || nginx -t && rcctl reload nginx
echo '<?php phpinfo(); ?>' > /var/www/example.com/html/info.php
curl http://localhost/info.php | grep 'PHP Version'
rm /var/www/example.com/html/info.php