【发布时间】:2014-07-08 16:27:34
【问题描述】:
如果这是基本的,请原谅我......我是配置方面的新手。
我已经构建了一个我想重用的 Web 应用程序,但它使用不同的域名提供较小的功能,以使一些基本用户更容易,我很难找出最好的方法来做到这一点。
我试图避免复制“管理”后端,因为它是相同的,只是带有一个不显示所有相同功能的菜单(我将处理使用 PHP 并基于$_SERVER['SERVER_NAME']。但是我需要两个不同的域名有单独的网页,这样我就可以展示两个不同的 web 应用程序。我不知道如何在 apache 中配置它,或者即使这是一个好的方法。我知道如何使用自己的文件夹结构创建两个单独的域,但我不知道如何让它们使用相同的管理员后端。
这就是我所拥有的。
/data/servers/www.website1.com/web
/data/servers/www.website2.com/web
我为这些域中的每一个都设置了一个虚拟主机,并且文档根目录指向每个不同站点的“web”文件夹。
在“web”文件夹下,我有以下结构 ./web/administrator
当用户访问“www.website1.com”时,需要为他们提供特定于该站点的网页。当用户访问“www.website2.com”时,需要为他们提供特定于#2 站点的网页。但是,每个站点都有一个“登录”链接,该链接指向位于“Adminstrator”文件夹内的“Login.php”页面。这就是我对如何使它工作感到困惑的地方。登录后,我希望应用程序使用“./www.website1.com/web/administrator”下的相同 Web 文件,这样我可以更轻松地管理维护。在应用程序中,我将根据用户来自哪个站点显示可供用户使用的菜单选项。我希望我可以使用我已经开发的“管理工具”,而不必分叉代码并维护 2 个单独的代码库,我希望保留 website1.com 的结构,因为它已经有用户,我怕把他们搞砸。
这可能吗?有人可以帮我弄清楚我需要做些什么来实现这一点吗?
这是我目前为 website1.com 设置虚拟主机的方式:
<VirtualHost 123.33.432.123:80>
# General setup for the virtual host
DocumentRoot "/data/servers/www.website1.com/web"
ServerName www.website1.com
ServerAlias *.website1.com
ServerAlias website1.com
ServerAdmin webmaster@website1.com
CustomLog "|/usr/local/sbin/cronolog /data/servers/www.website1.com/logs/access_log.%Y%m%d" "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
DirectoryIndex index.html index.php index.phtml index.htm index.php3 property-management-software.php
<Directory "/data/servers/www.website1.com/web/">
AddType application/x-httpd-php .php .html .htm
Options none
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
我想为 website2.com 添加另一个虚拟主机,如下所示:
<VirtualHost 123.33.432.124:80>
# General setup for the virtual host
DocumentRoot "/data/servers/www.website2.com/web"
ServerName www.website2.net
ServerAlias *.website2.net
ServerAlias website2.net
ServerAdmin webmaster@website2.net
CustomLog "|/usr/local/sbin/cronolog /data/servers/www.website2.net/logs/access_log.%Y%m%d" "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
DirectoryIndex index.html index.php index.phtml index.htm index.php3 property-management-software.php
<Directory "/data/servers/www.website2.net/web/">
AddType application/x-httpd-php .php .html .htm
Options none
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
【问题讨论】:
标签: php apache virtualhost