I'm building a deployment script and something seems wrong in the way Apache deals with my symlink.
I have a folder containing:
foo_svn: folder (my current website)
foo_tmp: folder (a copy)
web: symlink (pointing on foo_svn)
My DocumentRoot is set on web.
Before svnupdating foo_svn, I backup the contents in foo_tmp and I replace the symlink so that it points on foo_tmp.
Then I update foo_svn: let's say index.php has been modified. The website should be the same, since it now points on foo_tmp and that folder hasn't changed. And yet the page displayed is the new one, as if Apache looked directly for foo_svn/index.php instead of web/index.php.
In the vhost config file, DocumentRoot is still .../web, same as in the <Directory>. The symlink web still points on foo_tmp, and foo_tmp/index.php is still the old version.
EDIT: Digging a little deeper, it looks like there's something really weird with some kind of cache. Hard-reloading my page two times, sometimes it points first on foo_tmp, then on foo_svn, then on foo_tmp (then it stabilizes). Sometimes it just takes some time for the page to accept the new version (even hard-reloading). Sometimes it shows the new page in foo_svn too early, because the symlink is still pointing on the previous version in foo_tmp. I'm going insane over this, it's like Apache has a kind of "symlink cache," I don't know.
Related
Im currently trying to move a website to production that has been designed using contao. The website has been developed in a subdirectory of the current website. Now when I change the DocumentRoot to the contao directory the application automatically forwards me to the /development directory which in that situation does not exist anymore.
I did a database dump and searched it for "/development" to find the variable that is storing this information but I didn't find a match. I then did the same with the configuration files but it didn't show up any results too. How is redirecting handeled in contao?
It sounds like your pathconfig.php is wrong. After deploying/moving a Contao installation, you should always execute and log into the Install Tool under contao/install.php. This will correct your pathconfig.php.
Also make sure the RewriteBase in the .htaccess is set to the correct value (probably / in your case).
So I am at my wits end with this problem of trying to configure a simple Apache Web Server for one of my assignments. For some reason my changes to index.html are no longer being read, even though I got it to change previously.
I had this problem previously, where I would change index.html and it would still show the default "It works!" message. It ended up that, because my file extensions weren't shown, I had accidentally named the file index.html.html, and so obviously it wasn't locating it.
However, now that my file extensions are showing, I am having this problem again (the last fiasco was about a week or two ago). I tried changing the contents of index.html again, just a simple text change, and it is still loading my previous page. I have tried restarting Apache through Administrative Tools > Services since the Apache and httpd commands in the command line won't work for me. I even tried deleting the index.html file and leaving htdocs empty and it's still displaying my old web page!!!
I have no idea why it's doing this and I can't find any other answers. I checked my DirectoryRoot and DirectoryIndex values and they all point to index.html (and plus, I haven't touched httpd.conf since installation anyways). Running Windows 8.1. Any help greatly appreciated.
Modern Windows has a feature that copies some files when non-administrator edit them. You see the changes, but the service doesn't. Try editing your files as Administrator (not just someone with Administrator group privileges)
Sorry if I used the wrong terminology, I'm really new to web development/server stuff outside of Wordpress. I just made a DigitalOcean server and followed a bunch of tutorials to get it setup. I got my LAMP stack setup, but I got to the point in the tutorial where I created a quick php page and added it into /var/www as info.php. But when I go to my server IP/info.php, it couldn't find the page. It was only able to find the page when I moved it inside of /var/www/html which also contained index.html. My question is, what makes the browser/server look inside of html for files instead of /var/www?
My best guess is some apache config file that I'm not familiar with but I really have no idea.
Look in your apache httpd.conf file, most likely in /etc/httpd/conf on your server, for this command:
DocumentRoot "/var/www/html"
A client has a website running on a dedicated host (either developed, nor managed by myself) in which Apache is generating a very strange behavior.
When the requested url is of the type:
http://obituarieshelp.org/aboutus.html/whatever_here
it actually loads 'aboutus.html' if it exists, even though 'whatever_here' does not exist, and 'aboutus.html' is not a directory.
I took a look at the htaccess file, and everything seems to be fine. I am sure it is apache misconfigured somehow, but for the love of me, I cannot seem to find anything that could point to the problem in httpd.conf
Has anyone experienced the same, or has any suggestions as to why this would be?
This is controlled by the AcceptPathInfo HTTPd directive. The remainder of the path after the file is made available in the PATH_INFO environment/server variable, and scripts can use it to discern additional information about the request.
we are looking for a way to point our Apache DocumentRoot to a symlink.
E.g. DocumentRoot /var/www/html/finalbuild
finalbuild should point to a folder somewhere like /home/user/build3
when we move a new build to /home/user/build4 we want to use a shell script that changes the symbolic link "finalebuild" to this new directory /home/user/build4 and do an apache graceful restart to have a new web application version up and running with little risk.
What's the best way to create this symlink and to change this link afterwards using the shell script?
We're using capistrano to employ a similar setup. However, we've run into a few problems:
After switching to the setup, things appeared to be going fine, but then we started noticing that after running cap deploy, even though the symlink had been changed to point toward the head revision, the browser would still show the old pages, even after multiple refreshes and appending different GET parameters.
At first, we thought it was browser caching, so for development we disabled browser caching via HTTP headers, but this didn't change anything. I then checked to make sure we weren't doing full-page caching server-side, and we weren't. But I then noticed that if I deleted a file in the revision the symlink used to point to, we would get a 404, so Apache was serving up new pages, but it was still following the "old symlink" and serving the pages up from the wrong directory.
This is on shared hosting, so I wasn't able to restart Apache. So I tried deleting the symlink and creating a new one each time. This seemed to work sometimes, but not reliably. It worked probably 25~50% of the time.
Eventually, I found that if I:
removed the existing symlink (deleting it or renaming it);
made a page request, causing Apache to attempt to resolve the symlink but find it missing (resulting in a 404)
then created a new symlink to the new directory
it would cause the docroot to be updated properly most of the time. However, even this isn't perfect, and about 2-5% of the time, when the deploy script ran wget to fetch a page right after renaming the old symlink, it would return the old page rather than a 404.
It seems like Apache is either caching the filesystem, or perhaps the mv command only changed the filesystem in memory while Apache was reading from the filesystem on disk (doesn't really make any sense). In either case, I've taken up someone's recommendation to run sync after the symlink changes, which should get the filesystem on disk in sync with memory, and perhaps the slight delay will also help the wget to return a 404.
I've used symlinks as the apache DocumentRoot in production with no graceful restart necessary. In general, the idea should work. A 403 error probably indicates a permissions error unrelated to the symlink changing. An added wrinkle that you would want to add is making the symlink switch atomic so the symlink always exists. That is to say, at no time is the symlink nonexistent, even for a moment.
The solution to this problem is to effect the change by creating a new symlink and then renaming it over the old symlink. On Unix-like systems, renaming is an atomic operation, and thus the symlink “change” will be atomic too. By hand, the process looks like this:
$ ln -s new current_tmp && mv -Tf current_tmp current