Yii Framework Forum: Nginx for second Yii application - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Nginx for second Yii application frontend and backend

#1 User is offline   arsitek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 10-October 08

Posted 02 July 2016 - 10:41 PM

Hi,

UrlManger working well in the first application (frontend), but I have trouble for second Yii application for nginx setup. My second application is a directory '/admin'. I tried to follow Yii 2 model for frontend and backend nginx setup, but still won't work.

Server: ubuntu 16.04
Yii 1.17
Nginx 1.10.1
php 7

And here my current nginx setup

server {
    set $host_path "/var/www";
    access_log  /var/www/log/access.log;

    server_name  mysite.com;
    root   $host_path/html;
    set $yii_bootstrap "index.php";

    charset utf-8;

    location / {
        index  index.html $yii_bootstrap;
        try_files $uri $uri/ /$yii_bootstrap?$args;
    }

    #location /admin {
    #        return 301 /admin/;
    #}

    #location /admin/ {
    #        alias /var/www/html/;
    #        try_files $uri $uri/ @handler;

    #       location ~ \.php$ {
    #                include fastcgi.conf;
    #        }
    #}

    #location @handler {
    #        rewrite / /admin/index.php?$args;
    #}


    location ~ ^/(protected|framework|themes/\w+/views) {
        deny  all;
    }

    #avoid processing of calls to unexisting static files by yii
    location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
        try_files $uri =404;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php {
        include snippets/fastcgi-php.conf;
	fastcgi_pass unix:/run/php/php7.0-fpm.sock;
	fastcgi_split_path_info  ^(.+\.php)(.*)$;
	fastcgi_read_timeout 9999;

        #let yii catch the calls to unexising PHP files
        set $fsn /$yii_bootstrap;
        if (-f $document_root$fastcgi_script_name){
            set $fsn $fastcgi_script_name;
     }

        #fastcgi_pass   127.0.0.1:9000;
        #include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;

        #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
    }

    # prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }
}


Thank you
0

#2 User is offline   hrnair 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 243
  • Joined: 09-December 12

Posted 03 July 2016 - 01:00 AM

There was some discussions on the same issue two years before. The result was your problem did not get the solution.

Solution was obtained when the backend was used instead of '\admin' it was used as in the same form which we are getting.

So instead of one server variable - you should use 2 server variables
- root of each server variable will be webdirectory of backend\frontend respectively.

in this case prettyUrls work.


Forgot to add, you may have to use separate domains or subdomains for these two.

This post has been edited by hrnair: 03 July 2016 - 01:49 AM

1

#3 User is offline   arsitek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 10-October 08

Posted 04 July 2016 - 10:48 AM

:mellow:

Thank you..
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users