We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon and Nginx configuration in Plesk (11.5)

Hi all,

I've been working on a project with Phalcon in local development environment (Vagrant + Virtualbox). It just works great and my development time really decreased.

Now I would like to put this project online in a Plesk 11.5 nginx environment and I run into the problem of configuring Nginx in Plesk for Phalcon. I'm also quite new to Nginx.

I have the following Nginx configuration:

server {

    listen   80;
    server_name localhost.dev;

    index index.php index.html index.htm;
    set $root_path '/var/www/httpdocs';
    root $root_path;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}

I removed the "server {}" because those are not allowed in Plesk nginx configuration. However, it just doesn't work. The homepage of the application is shown perfectly, so Phalcon is running just fine, but the routing doesn't work: /search just gives a 404 where it does work in my local envoronment with this configuration.

What should I change in Plesk to make this work?

Thank you for your time in advance!



58.4k

Hey man

What is root website ?

The root is /var/www/vhosts/[website name].nl/dev.[website_name].nl/httpdocs I forgot to mention that I changed that also and I needed to remove the line "root $root_path;" because Plesk wouldn't allow me to set it.



58.4k

I think not possible remove "root $root_path"

Adding "root $root_path" gives the following error when you try to save the configuration:

Incorrect nginx-configuration: nginx: [emerg] "root" directive is duplicate in /var/www/vhosts/system/dev.[website_name].nl/conf/vhost_nginx.conf:6 nginx: configuration file /etc/nginx/nginx.conf test failed



58.4k

what is vhost file of you, please comment it in file nginx.conf

I think I found a solution in this article: https://abundantdesigns.com/2013/10/16/changing-the-nginx-document-root-on-plesk-11-5/ And in this one: https://stackoverflow.com/questions/20953120/plesk-nginx-config-for-every-domain-and-subdomain

I'm just trying to change configuration in the wrong place I guess. These articles describe a way to load a file with custom nginx domain settings. I don't have the required access rights to test this right now, but I will come back to let you know if this helped.

Thank you for your time so far!