我build立了一个Debain 6 VPS for PHP web developpement / personal hosting,并且有一个简单的问题:
我想要在/var/www/site.com中托pipe生产代码,并在/ home / username / public_html / site中开发代码
我已经设置了userdir.conf(我认为是默认设置):
<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>
我可以通过www.site.com和www.site.com/~username/site分别访问这两个代码库
我的问题是:什么是最好的方式限制www.site.com/~username/site(我的项目处于发展状态)到外面的世界? (.htaccess,虚拟主机设置等)
如果您从固定的IP地址连接到VPS,则将Allow from all更改为Allow from IP.AD.RE.SS变得快速而简单。 如果您不这样做,那么您可以使用.htaccess文件设置基本身份validation 。 把一些像
AuthType Basic AuthName Private Authuserfile /path/to/.htpasswd Require valid-user
在public_html / .htaccess文件中。
初始化.htpasswd文件
htpasswd -c /path/to/.htpasswd Purplefish32 New password: mypassword Re-type new password: mypassword Adding password for user Purplefish32
然后确保你的主Apacheconfiguration有一个合适的allowoverride指令,例如AllowOverride AuthConfig AuthConfig 。 如果需要重新启动Apache,现在应该要求您提供一个密码来访问您的开发文件的内容。