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 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/site.com, 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
            </Limit>
            <LimitExcept GET POST OPTIONS>
                    Order deny,allow
                    Deny from all
            </LimitExcept>
    </Directory>
</IfModule>

I can access both codebases via : www.site.com and www.site.com/~username/site respectively

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

share|improve this question
add comment

1 Answer

up vote 0 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 ip.ad.re.ss is dynamic you will have to edit the server config when it changes. –  Iain Mar 14 '12 at 10:26
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.