Apache:我希望每个用户拥有自己的DocumentRoot,例如〜/ www

我想configurationApache2,使每个用户有他/她自己的DocumentRoot而不是/var/www把文件放在/home/john/www (john是一个用户名smple)

Apache手册已涵盖 。 基本上,你需要在你的服务器configuration中启用一个模块,设置本地path,你就完成了。 在你的情况下,本地path应该是这样的:

 UserDir /home 

这会自动扩展到/home/username

在我看来,虽然,与public_html文件夹(或类似)是更好的。 这使您的用户可以存储无法通过networking访问的数据。

你需要Apache的mod_userdir模块:

http://httpd.apache.org/docs/2.2/mod/mod_userdir.html

具体来说,search你现有的configuration文件中的“UserDir”(可能在httpd.conf中,在extra / httpd-userdir.conf中,或者在其他文件中,取决于你在哪里获得Apache)。取消注释并将其设置为:

 UserDir www 

请记住启用mod_userdir模块(或取消注释httpd.conf中的“Include conf / extra / httpd-userdir.conf”,以适用者为准)以允许加载模块!