Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up a Debain 6 VPS for PHP web developpement / personal hosting and have a quick question :

I want to host production code in : /var/www/, and developpement code in /home/username/public_html/site

I have set up userdir.conf (Default setup I think) :

<IfModule mod_userdir.c>
    UserDir public_html
    UserDir disabled root

    <Directory /home/*/public_html>
            AllowOverride All
            Options MultiViews Indexes SymLinksIfOwnerMatch
            <Limit GET POST OPTIONS>
                    Order allow,deny
                    Allow from all
            <LimitExcept GET POST OPTIONS>
                    Order deny,allow
                    Deny from all

I can access both codebases via : and respectively

My question Is : What is the best way restrict (My project in developpement state) to the outside world ? ( .htaccess, virtualhost setup, other )

share|improve this question
up vote 1 down vote accepted

If you connect to the VPS from a fixed IP address then changing the Allow from all to Allow from IP.AD.RE.SS is quick and easy. If you don't then you could set up basic authentication using a .htaccess file. Put something like

AuthType Basic
AuthName Private
Authuserfile /path/to/.htpasswd
Require valid-user

In a public_html/.htaccess file.

Initialise the .htpasswd file

htpasswd -c /path/to/.htpasswd Purplefish32
New password: mypassword
Re-type new password: mypassword
Adding password for user Purplefish32

Then ensure that your main apache configuration has a suitable allowoverride directive e.g. AllowOverride AuthConfig. If required restart apache and now you should be asked to provide a password to access the contents of your development files.

share|improve this answer
I went with : Allow from IP.AD.RE.SS - Works perfectly, Thanks – Purplefish32 Mar 14 '12 at 10:20
Just be aware that if your is dynamic you will have to edit the server config when it changes. – Iain Mar 14 '12 at 10:26

Your Answer


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.