在AppFog上安装Vanilla

前一段写了篇Blog介绍Vanilla这个平台,以及在Ubuntu上的安装方法。也介绍过AppFog这个PaaS平台。在尝试在AppFog上安装Vanilla成功之后,把一些心得写在这里。

AppFog只能在运行时获取数据库的连接,因此修改`conf/config.php’,添加下面几行:

1
2
3
4
5
6
$services_json = json_decode(getenv("VCAP_SERVICES"),true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
$Configuration['Database']['Host'] = $mysql_config["hostname"]
$Configuration['Database']['Name'] = $mysql_config["name"];
$Configuration['Database']['User'] = $mysql_config["username"];
$Configuration['Database']['Password'] = $mysql_config["password"];

通过find . -name "*.php" -exec grep "'localhost'" '{}' -nH \;,可以发现applications/dashboard/controllers/class.setupcontroller.php文件中,对Database.Host设定了默认值为localhost,注释掉即可:

1
2
3
4
5
6
./applications/dashboard/controllers/class.setupcontroller.php:124: // $ConfigurationModel->Data['Database.Host'] = 'localhost';
./library/core/class.statistics.php:183: if ($ServerHostname == 'localhost' || substr($ServerHostname,-6) == '.local') return TRUE;
./library/core/functions.general.php:1076: function GetConnectionString($DatabaseName, $HostName = 'localhost', $ServerType = 'mysql') {
./library/vendors/Auth/OpenID/TrustRoot.php:210: if ($parts['host'] == 'localhost') {
./library/vendors/phpmailer/class.phpmailer.php:180: public $Host = 'localhost';
./plugins/Minify/min/lib/Minify/Cache/Memcache.php:13: * if ($memcache->connect('localhost', 11211)) {

附小广告一则:唱吧iOS团队诚招iOS工程师,推荐成功即奖励6000元现金或iPhone 6一部,详见这篇blog