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

June 12, 2018 274 views
Nginx Ubuntu 18.04

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;
        }
}
Be the first one to answer this question.