I have trying to configure AWS server myself.
Info1: EC2 as hosting and select Ubuntu 14 as OS and install Apache PHP and I have check that it php and http works. I have install Apache and php using below command:
sudo apt-get install apche2 php5 libapche2-mod-php5
and install MySQL client using
sudo apt-get install mysql-client-core-5.5
Info2: RDS as mysql database instance it is working.
Info3: When we trying to import sql from EC2 server using command it work
Info4: t2.micro as EC2 Instance and t2.micro as RDS instance
Issue:
When we try to connection RDS from a php script it showing error:
Call to undefined function mysqli_connect() in /var/www/html/awsmysql.php on line 3
My script code is:
<?php
echo "Create connection";
$con=mysqli_connect("awsmysqlhost","root","password1223","db");
echo "Check connection";
try{
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "Create database";
$sql="Select * from test";
if (mysqli_query($con,$sql)) {
$result = mysqli_query($con,"Select * from test");
while($row = mysqli_fetch_array($result)) {
echo $row['id'] . " " . $row['name'];
echo "<br>";
}
echo "Database my_db created successfully";
// var_dump($r);
} else {
echo "Error creating database: " . mysqli_error($con);
}
}catch(Exception $e)
{
echo "<pre>";
var_dump($e);
echo "</pre>";
}
?>
Question(s):
Is need to install some MySQL or PHP to library which will connect EC2 with RDS and running the system?
Need some Apache Configuration at EC2 Instance?
Is there need some setting at AWS?
apt-get install php5-mysql
– slayedbyluciferphp5-mysql
. Hence try installing it and check if it works. – slayedbylucifer