Nginx & Yii2 only with IP


I have a VPS server installed on Ubuntu Server 14.04, as a Nginx 1.9 web server and I am about to put into production a Yii2 developed project. The server is accessed by public IP and the configured of the nginx is the following form:

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

            root /var/vhosts/sac.local/rem;
            autoindex on;

            index index.php index.html index.htm index.nginx-debian.html;

            access_log /var/log/nginx/sac.access.log combined;
            error_log /var/log/nginx/sac.error.log;

            server_name _;

            location / {
                    try_files $uri $uri/ =404;

            location ~ \.php$ {
                   try_files $uri =404;
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_intercept_errors on;
                    fastcgi_read_timeout 600;
                    include fastcgi_params;


I have tried adding an additional location with an alias to indicate the project route, but I can not lift the project.

Basically I need to add a configuration in such a way that the project is accessed: link

Any ideas?

asked by Ale 13.02.2016 в 00:37

1 answer


you should have a location like this:

location /v3 {
    try_files $uri $uri/ =404;

so that if you fit the route with v3, try to use the $ uri delivered. To extend a bit, having this:

location ~ \.php$ [...]

you are saying that any route that ends in php is executed by defining it within, that is, by php-fpm.

Now if you want your default route to redirect to / v3, it's something else

answered by 30.03.2016 в 12:17