Web Hosting Talk







View Full Version : Need Apache2 to ignore missing DocumentRoot


ConeMan
06-12-2009, 12:38 AM
Hi Guys,
As an ISP, we offer Apache virtual hosting for 400+ domains. We have the occasional issue where a client unwittingly deletes their public_html (DocumentRoot) directory. Later when Apache is asked to restart (even gracefully), it fails telling me that a certain DocumentRoot directory doesn't exist. As you can probably guess, all a client needs to do to disrupt web hosting for every other client on the server is rename their public_html and wait.

I run at least 1 other apache2 server that will warn on startup if a documentroot directory is missing, but continue to start up. I have spent hours today comparing the startup, envvars, vhost and module configs and almost worn Google out trying to find what to do to make my other servers do the same. All of my servers are Debian 5 (Lenny) running Apache 2.2.

Any ideas?

TIA

-- Chris

Loggy48
01-12-2012, 06:11 AM
@ConeMan or anyone - did you find the solution to this?

This has been worrying me for some time and any user with ftp access would be able to upset my system, let alone other ways of doing it.

I am using Ubuntu 10.04 LTS server, Apache2.2.14-5ubuntu8.7.

lazat
01-12-2012, 10:58 AM
Hi

Inside the public_html dir you create a hidden file .readme and set the owner to root.

You can't delete the directory becouse its not empty. And the customer can't delete a file that owns by root.


2. Solution 2
Create a perl script that parces trought the apacheconf and creates all missing files/dirs.

Loggy48
01-12-2012, 11:11 AM
Hi

Inside the public_html dir you create a hidden file .readme and set the owner to root.

You can't delete the directory becouse its not empty. And the customer can't delete a file that owns by root.


2. Solution 2
Create a perl script that parces trought the apacheconf and creates all missing files/dirs.

That's two really good ideas that I will implement - in fact you only need to grep DocumentRoot from /etc/apache2/sites-enabled and check for the existence, making the directory recursively if it doesn't exist. And I like the .readme.txt file idea too.

But it would still be easier if Apache could ignore the DocumentRoot. Then trying to access a missing site should just fall back on the default. In 2.2.17 there seems to be a -T option which does just that. I was wondering whether ConeMan did find how one of his servers warned and the other barfed at him!

dareORdie
01-12-2012, 11:19 AM
Can you provide me error here that's better way ?

lazat
01-12-2012, 11:30 AM
You also need to check that the log files exist.

btw. I will give you a tip that i use. I have about 500 vhosts / server and we have a perl script that creates a vhost-domain_com.conf and places that file in a directory that apache parses every night.

Becouse the files are created every day we could replace the accesslog with todys date in the vhost file. This way we don't eat up 2x file descriptors for every vhosts that have logging enabled. Also its easy to add other functions to vhost every file if you add other syntax to vhost like serveralias lines. All is driven from a MYSQL-backend.

Loggy48
01-12-2012, 11:41 AM
That's another good idea that is similar to something I have been working on although I still retain separate conf files (and log files) that are set up when the site is initiated. This would work well with lighttpd as well as it could write the whole config file in one go, although as most sites are Wordpress and people use their individual permalinks, this would be quite messy (may well have to move to Lightspeed).

So far I haven't had descriptor problems but it may well happen. One thing that I am including is automatic 301 redirection rather than server aliasing so that they are all regarded as the same by search engines etc.

lazat
01-12-2012, 11:47 AM
But the best solution is to stop use apache. It sucks....

Loggy48
01-12-2012, 12:12 PM
I agree but the trouble is that many things need .htaccess and AFAIK the only drop-replaceable server is Lightspeed. :-(