If have an amazon ec2 instance running php 5.5 and apache2. I am connecting to my RDS database using a simple test.php script. When I run the script as ec2-user or as root I am able to get a connection. When I run the same script via my webserver I get
Connection Can't connect to MySQL server on 'ip' (13).
I've tried the public and private IP addresses. This script does work from my other, non-amazon, webservers running the same php and apache. Not sure what to look at next since it works on the command line.
define("DB_IP”,”ip”);
define("DB_USERNAME”,”username”);
define("DB_PASSWORD”,”password”);
define("DB_DATABASE”,”database”);
echo "Connecting...\n";
$conn = new mysqli(DB_IP, DB_USERNAME, DB_PASSWORD, DB_DATABASE, 3306);
// Check connection
if ($conn->connect_error) {
die(date('H:i:s')." Connection " . $conn->connect_error);
}
echo date('H:i:s')." Connected successfully\n";
Aucun commentaire:
Enregistrer un commentaire