首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache配置

Apache配置
EN

Ask Ubuntu用户
提问于 2016-04-28 15:11:55
回答 2查看 371关注 0票数 0

我是Ubuntu的新手,我将Apache配置为从我的主目录站点目录读取根目录文档。

我编辑了/etc/apache2/available下的(默认)文件--从/home/username读取的站点

当我重新启动Apache时,它将从我的主目录读取为默认页面

我试图通过让用户(如http://localhost/~user1/ )访问Apache本地主机

我怎么能这么做?

EN

回答 2

Ask Ubuntu用户

发布于 2016-04-28 16:02:33

此功能可通过以下方式启用Apache userdir模块:

代码语言:javascript
复制
sudo a2enmod userdir

下一步是配置您希望Apache如何处理URI。

下面是一些例子:

  • 如果希望从http://localhost/~user1/site1目录加载URL /home/user1/site1,则需要使用UserDir。
  • 如果希望从http://localhost/~user1/site1目录加载URL /home/user1/sites/site1,则需要使用UserDir站点

若要添加配置,并假设您使用的是Apache2.2,请创建以下文件/etc/apache2/conf.d/userdir.conf并向其添加以下内容:

代码语言:javascript
复制
# This is just a safety measure to make sure the root user isn't used.
UserDir disabled root

# Swap the following line with whatever configuration you require.
UserDir sites

# If you chose "UserDir ./" instead of "UserDir sites",
# remove the "sites/" part in the next line
<Directory /home/*/sites/>
    Order allow, deny
    Allow from all
</Directory>

完成之后,您需要重新启动Apache:

代码语言:javascript
复制
sudo apache2ctl restart
票数 3
EN

Ask Ubuntu用户

发布于 2016-04-28 15:50:59

您可以为每个人定义不同的virtualhost和不同的servernamedocument root。但是您应该为每个用户编辑/etc/hosts。例如:Virtualhost *:80 Servername : person 1 Document root : /home/person1,也可以将home目录定义为document root,每个用户都可以找到他/她的目录。

请注意,您应该给www-data的所有者在他们的家和许可做他们的工作人员。

PS :为什么你不尝试你的场景的vsftpd ?!这样会更好。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/764382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档