您好我正在尝试在AWS EC2和RDS中部署我的项目。我们使用Symfony 3.4 Framework开发了我们的应用程序,我在localhost中的代码工作正常,没有任何问题。
在AWS中托管后无效。显示此错误
"message": "An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known",
邮差错误信息:
{
"error": {
"code": 500,
"message": "Internal Server Error",
"exception": [
{
"message": "An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known",
"class": "Doctrine\\DBAL\\Exception\\ConnectionException",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/var/www/html/ApartmentManagementScms/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php",
"line": 93,
"args": []
},
]
},
]
}
}
AWS中的Apache版本:
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2018-06-07T19:43:03
OS版本:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
仔细检查您在DSN中指定的主机地址。此错误只是表示无法解析为mysql主机指定的名称。
检查.env文件中的数据库配置
DATABASE_URL = MySQL的:// yourdbusername:[email protected]:3306 / yourdbname