Report this

What is the reason for this report?

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

Posted on June 12, 2018

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;
        }
}


This textbox defaults to using Markdown to format your 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.

Hello,

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

https://marketplace.digitalocean.com/apps/lemp

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:

https://www.nginx.com/resources/wiki/start/topics/recipes/zend/

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.