After a good looking for something that realy works on Ajenti (my best personal server admin), i couldn't understand why does any configuration they posted about this enviroment doesn't work at all!!

So i have a solution for any soul that are looking for this. First lets take a look in the versions that i'm working with:

• Ajenti: 1.2. (works in 1.1, with ajenti-v)

• Nginx: 1.10 (i dont think the version of this can really make a diference)

• PHP7.0-fpm (works on 5.6 and 7.1. I didin't test other, but it makes no diference here, because my focus is the ajenti itself. Ajenti have the modules for all versions, with a just a little search on the web to know how to install they)

• Phalcon 3 (works great on any version of it, since 1.3)

First thing you have to know, is that ajenti-v have a lot of configuration, but despite it check their folders and permissions and database, he just write on nginx configuration file that are located on /etc/nginx/conf.d folder. He recreate this link folder every time you change somenthing on your server, checking folders permissions for FTP, checks database and reloading nginx for it works.

First thing i've looked for this configuration was the phalcon's site tutorial for nginx, but when you put this configuration on your website he rejects and fails to restart. It doesn't matter where did you put this configuration, he rejects it, just because some of this lines are already configured when ajenti writes this file.

And so, with a big searching, i stepped into the wordpress configuration for ajenti-v. These posts i found doesn't worked at all. The mistakes was simple: or the discussion is for some older version of the configuration, or it stepped on the same error of phalcon's config pages.

I had to study the nginx settings to make it work. I'm not an specialist on this engine, but i got some conclusions:

• Ningx does not accept a duplicated configuration on the same server. E.g.:

server{
    location / { ... }
    location / { ... } //this is the repeated rule. It will breaks your nginx
}

• Nginx does not accept the same server_name on the same config file, but it accept as many servers you like to make any domain and subdomaind working with it(this config is for subdomains and etc.). E.g.:

server {
    listen *:80;
    server_name my_domain;
}
server {
    listen *:80; //it ignores anything else
    server_name my_domain; //this will give nginx error and fails to start
}

• php-fpm(5.5,5.6,7.0,7.1) works with a socket that ajenti-v creates for each domain you have, based on the server name without dots, spaces, and any char different of alphanumeric chars. This is the "config" name of your domain in ajenti-v. E.g.: my-domain.com.eu -> mydomaincomeu.

Lets do the trick. Based on this, the configuration is very simple to do:

• First remove any domains that you have putted to respond as your website configuration on the "domain" tab.

• Apply "static files" to work as "exact" files on your content server. Put php to work on this, with the same configuration "exatc". E,g: Mine is setted as ".php" "exact", and work just fine.

• It doesn't matter which folder, db or ftp config you put in it. Just remember to configure your exact ftp configurations to work in root folder of your site. In the new ajenti you have to create this folder, but remember that in phalcon the folder you will work as root is "/public".

your folder will be:

/srv/mydomain.com.eu
         /app
         /public
         /vendor
         /...

So in the initial folder just create the root folder inside "srv" folder, and do the rest on ftp.

Save this setting. It will generate this file in conf.d named as your domain "mydomaincomeu.conf" inside the folder for nginx:

#AUTOMATICALLY GENERATED - DO NO EDIT!

server {
    listen *:80;

    access_log /var/log/nginx/mydomaincomeu.access.log;
    error_log /var/log/nginx/mydomaincomeu.error.log; //this name is based on "config" name created by nginx

    root /srv/mydomain.com.eu; //this is your folder name
    index index.html index.htm index.php;

    location  / {

    }

    location  .php {

        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/ajenti-v-php7.0-fcgi-mydomaincomeu-php7.0-fcgi-1.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

}

This config work without server_name, so it won't work! But now with this, you have the initial config and socket name. It's time to you make your own server configuration. It have to be like this:

server {

    listen *:80;
    server_name mydomain.com.eu www.mydomain.com.eu;
    root /srv/mydomain.com.eu/public;
    index index.html index.htm index.php;
    charset     utf-8;

    access_log /var/log/nginx/mydomaincomeu.access.log;
    error_log /var/log/nginx/mydomaincomeu.error.log;

    location / {
        try_files $uri $uri/ /index.php?_url=$uri&$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/ajenti-v-php7.0-fcgi-mydomaincomeu-php7.0-fcgi-1.sock;
        fastcgi_index index.php;

        include fcgi.conf;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
           access_log off; log_not_found off; expires max;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ /\.ht {
        deny all;
    }

}

Note that this config server script have some aditional things to protect and upgrade your server protection and speed, somethings that i've learned from wordpress config. It's not mandatory, but for me works as a shining glove. The mandatory config is:

server {
    listen *:80;
    server_name mydomain.com.eu www.mydomain.com.eu;
    root /srv/mydomain.com.eu/public;
    index index.html index.htm index.php;
    charset     utf-8;

    access_log /var/log/nginx/mydomaincomeu.access.log;
    error_log /var/log/nginx/mydomaincomeu.error.log;

    location / {
        try_files $uri $uri/ /index.php?_url=$uri&$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/ajenti-v-php7.0-fcgi-mydomaincomeu-php7.0-fcgi-1.sock;
        fastcgi_index index.php;

        include fcgi.conf;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

The rest of this script, it's by yourself. Put this on Advanced->Custom top level configuration field. Save this and Cheers!!

Now config your db, upload your files and see it working.