we're searching for a method to point our Apache DocumentRoot to some symlink. E.g. DocumentRoot /var/www/html/finalbuild

finalbuild should indicate a folder somewhere like /home/user/build3

whenever we move a brand new build to /home/user/build4 you want to make use of a spend script that changes the symbolic link "finalebuild" for this new directory /home/user/build4 and do an apache elegant restart to possess a new web application version ready to go with little risk.

What's the easiest method to create this symlink and also to change this link later on while using spend script?

I have used symlinks because the apache DocumentRoot being produced without any elegant restart necessary. Generally, the concept should work. A 403 error most likely signifies a permissions error unrelated towards the symlink altering. An additional wrinkle that you would like to add is making the symlink switch atomic therefore the symlink always is available. In other words, never may be the symlink nonexistent, even as it were:

We are using capistrano to train on a similar setup. However, we have encounter a couple of problems:

After switching towards the setup, things made an appearance to become going fine, however we began realizing that whenever running cap deploy, despite the fact that the symlink have been transformed to suggest toward the mind revision, the browser would still show that old pages, despite multiple refreshes and appending different GET parameters.

In the beginning, we think it is browser caching, so for development we disabled browser caching via HTTP headers, but this did not change anything. Then i checked to make certain we were not doing full-page caching server-side, and that we were not. However I then observed when I erased personal files within the revision the symlink accustomed to indicate, we'd obtain a 404, so Apache was serving up new pages, however it was still being following a "old symlink" and serving the web pages up in the wrong directory.

This really is on hosting that is shared, and so i wasn't in a position to restart Apache. And So I attempted removing the symlink and creating a replacement every time. This appeared to operate sometimes, although not dependably. It labored most likely 25~50% of times.

Eventually, I discovered when I:

  1. removed the present symlink (removing it or renaming it)
  2. designed a page request, leading to Apache to try to resolve the symlink but think it is missing (producing a 404)
  3. then produced a brand new symlink towards the new directory

it might make the docroot to become up-to-date correctly more often than not. However, even this is not perfect, contributing to 2-5% of times, once the deploy script went wget to fetch a webpage immediately after renaming that old symlink, it might return that old page as opposed to a 404.

It appears like Apache is either caching the filesystem, or possibly the mv command only transformed the filesystem in memory while Apache was reading through in the filesystem on disk (does not really make sense at all). Either in situation, I have adopted someone's recommendation to operate sync following the symlink changes, that ought to obtain the filesystem on disk synchronized with memory, and possibly the slight delay will even assist the wget to come back a 404.