将CakePHP应用程序部署到AWS ElasticBeanstalk EC2实例

时间:2014-07-21 06:16:06

标签: php cakephp amazon-web-services amazon-ec2 cakephp-1.3

我正在尝试设置我的第一个AWS EC2实例来部署我现有的CakePHP应用程序。该应用程序在本地运行良好,但我似乎无法在EC2实例上获取应用程序以连接到数据源。在尝试加载应用程序时,我在页面顶部出现以下错误集:

Warning (2): mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 561]
Warning (2): mysql_query() expects parameter 2 to be resource, boolean given [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 613]
Warning (2): Cannot modify header information - headers already sent by (output started at /var/app/current/cake/libs/debugger.php:686) [CORE/cake/libs/controller/controller.php, line 742]
Warning (2): mysql_errno() expects parameter 1 to be resource, boolean given [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 695]
Warning (2): Invalid argument supplied for foreach() [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 127]
Warning (2): array_keys() expects parameter 1 to be array, boolean given [CORE/cake/libs/model/datasources/dbo_source.php, line 1967]
Notice (8): Trying to get property of non-object [CORE/cake/libs/model/datasources/dbo_source.php, line 811]
Warning (2): mysql_real_escape_string() expects parameter 2 to be resource, boolean given [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 684]

应用实时网址: http://orderaslice-demo.elasticbeanstalk.com/

我一直在关注如何将Cake应用程序部署到实例的AWS教程,但一切看起来都是正确的: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_cakePHP.html

我的数据库配置文件在这里。它的设置与教程相同:

if (!defined('RDS_HOSTNAME')) {
  define('RDS_HOSTNAME', $_SERVER['RDS_HOSTNAME']);
  define('RDS_USERNAME', $_SERVER['RDS_USERNAME']);
  define('RDS_PASSWORD', $_SERVER['RDS_PASSWORD']);
  define('RDS_DB_NAME', $_SERVER['RDS_DB_NAME']);
}
class DATABASE_CONFIG {
        //live server (Amazon ECS)
        var $default = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'RDS_HOSTNAME',
                'login' => 'RDS_USERNAME',
                'password' => 'RDS_PASSWORD',
                'database' => 'RDS_DB_NAME',
                'prefix' => '',
        );
}

先感谢大家!

1 个答案:

答案 0 :(得分:0)

您在db配置中使用字符串,而不是您定义的常量。