Nginx is working fine with root path without symbolic links(Eg.../1.0/public). When a symbolic link is used(Eg.../current/public where current is a link to 2.0) the changes don't get affected until I change the name of the old target folder. I am using nginx version 1.13.6.

I have given disable_symlinks off; in my nginx.conf. Can someone tell me how to specify root path with symbolic links in nginx and use those links to point to different targets without restarting nginx so that the UX is not disturbed and the change is seamless?

closed as off-topic by Jeff Schaller, Satō Katsura, slm Jun 12 '18 at 0:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, Satō Katsura, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Would an nginx reload not be enough? Not a restart, but "kill -HUP" of nginx' PID. – Gerard H. Pille Jun 7 '18 at 8:53
  • Yes. But, that would break any existing HTTP connections. So, I would prefer using symbolic links to redirect to the targets. I have other applications being served through nginx on the same VPS as well. – TrickyExplorer Jun 8 '18 at 5:08
  • A reload does not "break" existing connections, that's what it's for. – Gerard H. Pille Jun 8 '18 at 6:55
  • Thanks for your solution. I got this done using symlinks and my answer is below. – TrickyExplorer Jun 8 '18 at 12:31

The issue was because fastCGI was caching the path. When the line in the nginx config:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; in the php location block was replaced with:

fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

every change gets affected immediately.

Not the answer you're looking for? Browse other questions tagged or ask your own question.