What is the virtual host configuration for a ZF3 application with nginx?

What is the correct virtual host configuration for a Zend Framework 3 application on Ubuntu 18.04 with Nginx? Here mine:

server {
        listen 80;
        listen [::]:80;

        server_name dev.myapp.local;

        root /var/www/NetBeansProjects/myapp/public;
        index index.php index.html;

        location / {
                try_files $uri $uri/ @php;

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;

        location ~ /\.ht {
                deny all;

        location @php {
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                fastcgi_param SCRIPT_FILENAME /var/www/NetBeansProjects/myapp/public/index.php;
                include fastcgi_params;

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


What you could do is first to deploy a LEMP instance using this 1-click installation here:

This will ship with an Nginx server block that should work for most PHP frameworks so you would not really have to make any changes.

Alternatively, you can use the one from the official docs here: