3

我在一些 VPS(朋友的带有 cPanel 的 apache 服务器)上有一个帐户,并且我有一个 public_html 目录。我们在那里有大约 5-6 个网站:

/home/myusername/public_html/domain-1.name/index.php
/home/myusername/public_html/domain-2.name/index.php

但我不喜欢这种方式,我想更好地组织它,并能够为每个网站分离和隔离一些东西。那么,如果我这样创建会怎样:

/home/myusername/websites/domain-1.name/public_html/index.php

/home/myusername/websites/domain-2.name/public_html/index.php and so on

这会是构建 Web 目录的正确方法吗?apache会这样工作吗?也许还有其他一些约定或常见的解决方法?

谢谢

4

3 回答 3

1

这很好。事实上,我强烈建议不要使用域文件夹作为文档根目录,因为典型的 Web 应用程序还将包含不可公开访问的数据(例如配置文件、管理脚本、版本控制文件等)

我个人更喜欢这个名字htdocs,我把我的网站放在下面/srv/http

例如:

/srv/http/user1/domain1/htdocs/
/srv/http/user1/domain2/htdocs/
/srv/http/user1/domain3/htdocs/
/srv/http/user2/domain4/htdocs/
/srv/http/user3/domain5/htdocs/

这样,您可以将 设置DocumentRoothtdocs目录并将其他不打算由 Web 服务器交付的内容放在域目录的不同子目录中。

于 2013-01-28T22:18:46.917 回答
1

好的,我只想总结并概述我的方式。
感谢@bikeshedder 的想法!

因此,在 linux VPS 服务器下拥有一个单独的帐户(非 root)/home/myusername/,我不想完全从现有的目录结构中抽象出来,但同时我想创建适当的环境来隔离和分离客户端及其空间。

主要目标是:
* 新的目录结构应该有助于使所有文件和文件夹保持良好和清晰的顺序。
*易于导航和浏览。
* 每个开发人员或客户只能访问他们的空间。

结构:

/home/myusername/http/client-1/domain-1/public_html/index.php
/home/myusername/http/client-1/domain-1/resources/
/home/myusername/http/client-1/domain-1/configuration.php
/home/myusername/http/client-1/domain-2/public_html/index.php
/home/myusername/http/client-1/client's_resource_dir/  

/home/myusername/http/client-2/domain-3/public_html/index.php
/home/myusername/http/client-2/domain-3/subdomain/public_html/index.php

结果:
* 我们隔离了客户空间和隔离域空间。这为任何类型的 Web 项目提供了足够的空间。
* 文件和目录不再与其他项目、域和客户端混在一起。
* 对于子域路径,它可以是
- 作为子目录/domain-3.name/subdomain/public_html/
- 或附加的子域目录/subdomain.domain-3.name/public_html/,具体取决于子域网站的要求或大小。
* Public_html将成为每个网站的DocumentRoot

我没有选择目录srv/var/www因为对我来说这听起来像是服务器中的服务器,而且我不觉得var/当前设置中的可变数据属于网络内容。
虽然这对我们即将推出的本地网络/文件共享服务器可能有意义

但是现在我有另一个问题:
如何将新路径指定为 cPanel 的默认路径?并且仅适用于我的用户?
因为现在一个用户空间中将有多个DocumentRoot目录。
Apache设计有可能吗?
我最好创建新问题:) 然后用答案编辑我的问题

欢迎任何建议!

于 2013-01-29T15:25:35.400 回答
0

通常从 5-30++ 个站点托管一次,具体取决于内容的复杂性、流量、感知到的未来迁移策略到更专用的虚拟或裸机服务器/实例。

/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/assets/...

/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/assets/...

/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/assets/...

/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/assets/...

/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/index.<html|php|jsp|aspx|what-not>
/<node-serial-or-hostname-or-domain>/<@|subdomain|www|others>/assets/...
于 2017-05-13T08:03:52.923 回答