I am attempting to set up my first AWS EC2 Instance to deploy an existing CakePHP application of mine. The application works perfect locally, but I can't seem to get the application on the EC2 instance to connect to the datasource. Upon trying to load the app, i get the following set of errors on the top of the page:
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]
Application Live URL: http://orderaslice-demo.elasticbeanstalk.com/
I have been following the AWS tutorial on how to deploy a Cake app to the instance, but everything appears to be correct: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_cakePHP.html
My database config file here. It was set up same way as tutorial:
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' => '',
);
}
Thanks in advance to everyone!
您在数据库配置中使用的是字符串,而不是定义的常量。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.