【问题标题】:cakephp - one framework, a few apps on localhost subdomaincakephp - 一个框架,本地主机子域上的一些应用程序
【发布时间】:2011-05-03 10:02:24
【问题描述】:
如何准备 CakePHP 框架以在一个 CakePHP 框架中为多个应用程序工作?
我想准备这样的结构文件夹:
- app1/
- app2/
- app3/
- 蛋糕/
- 供应商/
- 插件/
- index.php
我想使用http://app1.localhost/ 从 app1/ 文件夹运行应用程序吗?
有可能吗?
【问题讨论】:
标签:
cakephp
subdomain
localhost
structure
directory
【解决方案1】:
基本上,您需要做的就是正确配置每个应用程序的app/webroot/index.php 文件以指向正确的ROOT/cake 文件夹。剩下的就是 Apache 虚拟主机配置,将子域指向正确的应用文件夹。
【解决方案2】:
我正在运行 XAMPP,但我假设您正在您的机器上运行类似的东西。无论如何,进入您的apache\conf 文件夹并打开httpd.conf 文件。 XAMPP 有一个名为 apache\conf\extra\httpd-vhosts.conf 的文件,它更适合添加虚拟主机。
所以你想像这样输入适当的指令......
<VirtualHost *:80>
ServerAdmin postmaster@localhost
DocumentRoot "C:/path-to-your-app-webroot-folder-no-trailing-slash"
ServerName app.localhost
##ServerAlias www.dummy-host.localhost
ErrorLog "logs/app.localhost-error.log"
CustomLog "logs/app.localhost-access.log" combined
<Directory "C:/path-to-your-app-webroot-folder-no-trailing-slash">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
此外,如果您使用的是 Windows XP,您需要在 127.0.0.1 app.localhost 的 C:\Windows\system32\drivers\etc\hosts 文件中输入一个条目来解析子域。这应该可以完成工作。