Score:1

nginx slow symlink subfolder

cn flag

I have two domains, like this:

  1. www.main.com in /var/www/www.main.com (without /public)
  2. system.main.com in /var/www/system.main.com (with /public)

In the first one I have a subfolder www.main.com/sub that sym-links to the second domain.

/var/www/www.main.com/sub => /var/www/system.main.com/public

To make PHP (FPM) work in the /sub I used this config:

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

That works fine but is very slow.

Simple request on www.main.com/sub takes 600ms, while the same request on second domain directly takes 100ms.

Does anyone knows why this is slow and how to fix it?

What I tried

Following this I tried including the other project root and PHP more direct but could not get it working:

location /sub {
    alias /var/www/system.main.com/public;
    index index.php;
    try_files  $uri $uri/ /index.php?$args ;

    #if (!-e $request_filename) { rewrite ^ /index.php last; }

    location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/lib/php7.0-fpm/web8.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT $realpath_root;
                fastcgi_intercept_errors on;
    }
}

Update

I got it working for index.php but still have trouble with any path.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.