我在一些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会像那样工作吗?也许还有一些其他的约定或通用的变通方法?
谢谢
发布于 2013-01-29 06:18:47
这是非常好的。事实上,我强烈建议不要使用域文件夹作为文档根目录,因为典型的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/这样,您可以将DocumentRoot设置为htdocs目录,并将web服务器不打算交付的其他内容放在域目录的不同子目录中。
发布于 2013-01-29 23:25:35
好了,我只想总结一下,并概述一下我所采用的方法。
感谢@bikeshedder的点子!
因此,在linux服务器下有一个帐户(非根) /home/myusername/,我不想完全从现有的目录结构中抽象出来,但同时我想创建适当的环境来隔离和分离客户端及其空间。
的主要目标是:
\* The new directory structure should help to keep all files and folders in a nice and clear order. \* Easy to navigate and browse. \* Each developer or client would have access only to their space. 结构:
/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项目提供了足够的空间。
*文件和目录不再与其他项目、域名和客户端混淆。
*对于子域路径,可以是
- as subdirectories `/domain-3.name/subdomain/public_html/`
- or additional subdomain directory `/subdomain.domain-3.name/public_html/`depending on requirements or size of subdomain website.* Public_html将成为每个网站的DocumentRoot。
我没有使用srv/和var/www目录,因为对我来说,它听起来像服务器中的服务器,而且我也不觉得当前设置中的可变数据var/属于web内容。
尽管它可能对我们即将到来的本地web/文件共享服务器有意义
但现在我有另一个问题:
如何将新路径指定为cPanel的默认路径?而且只针对我的用户?
因为现在在一个用户空间中将有多个DocumentRoot目录。
通过Apache设计,这是可能的吗?
我最好创建一个新问题:),然后用answer编辑我的问题
欢迎任何建议!
发布于 2017-05-13 16:03:53
通常情况下,根据内容的复杂性、流量、感知的未来迁移策略,从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/...https://stackoverflow.com/questions/14572197
复制相似问题