I have two domains, like this:
www.main.com
in /var/www/www.main.com
(without /public)
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.