Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to have Apache require a restart in order for it to recognize any changes to htdocs.

Is this possible?

share|improve this question
3  
I gotta ask - Why? –  John Gardeniers Oct 12 '10 at 20:55
    
while not an exact solution. You could have a MAC setup like SELinux to where you can't change the files unless you change the rules which would require a reset –  PHGamer Oct 12 '10 at 21:36
add comment

migrated from stackoverflow.com Oct 12 '10 at 20:31

This question came from our site for professional and enthusiast programmers.

2 Answers

By "htdocs", do you mean the entire contents of your website? If so, then the answer is "maybe" by using mod_cache+mod_disk_cache. You'll need to run some kind of spider to crawl all your pages so that Apache loads them all into the cache, configure the expiration date for everything millions of seconds into the future, and turn on just about all of the options that apache warns against due to serving "stale" pages. This isn't a perfect idea though... if there's any files the spider misses or if you add new files to your htdocs directory, people will be able to see them (and add them to the cache for everyone else) if they can figure out the URL. You might be able to figure out how to use the security warning here to your advantage by allowing everyone to access the cache but not the actual site but I suspect that everyone else would consider trying to do that a "bug" rather than a "feature". When you want to update the site, you'll have to erase all of the cached files and re-spider the site.

Without knowing what you're trying to do, I can only guess at better ideas. If you are just making changes to your website and don't want anyone to see them until you're done, then what you should do is have two different directories with a copy of your website. The Apache configuration should point to one directory as DocumentRoot while you make changes in the other. When you're done making changes, you edit the Apache configuration, point DocumentRoot to the other directory and restart Apache so the new site is live.

share|improve this answer
add comment

I don't see any out of the box solution.

However My idea would be this:

You set up your server so that the DocumentRoot and the FTP directory are different. Then you write a script which copies all the files located in the FTP directory to the DocumentRoot direcory.

You can do that easily with rsync.

You can even insert this script in the /etc/init.d/apache2 file. This way, when you do a service restart or reload (with service apache2 restart|reload), all files are updated in the DocumentRoot directory.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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