I'm a little bit frustrated with a problem I'm having in a system migration from AWS to GCE.
I've an ec-2 instance running on amazon web services, perfectly working and configured.
The problem is that google is offering a 100.000$ credit in a special plan for Startups, my company's CEO asks for a migration, so here I am.
I have all running and almost fully configured in a ubuntu 14.04 LTS instance, I said almost, because I can't achieve a simple task such as connect to a Mysql db :(, and I think I'm missing something in someplace and my mind gets offuscated, so I need your help.
First of all, I only having this problem on remote server, I've tested it like a hundred times in local, and of course in aws, where it is currently in production state, so I have no clue what or where exactly the problem is.
My GCE config:
OS: Ubuntu 14.04 LTS HHD: 30GB persistence ssd disk CPU : 2x RAM : 7,5 GB Zone: europe-west1-c Static Ip
So, I installed Lamp and phpmyadmin, all works like a charm. I disable root access from remote clients to Mysql db, configured php and apache modules.
The Web app is a Rest Api, based on PHP(Slim), that, like I just said, is now working on AWS.
When I call to and endpoint that doesn't need to retrieve any data from the db, it works well, the problem comes when the endpoint called try to access the db. In that case the request never respond, it keeps loading forever until I abort the request. It is kind of weird, because I can manipulate all the data through phpmyadmin, which access to the db the same way mysqli does.
If I checked the logs, nothing is printed on them. Only when I change the "locahost" host param, it prints a log saying: "No mysql db on XXX.XXX.XXX.XXX"(IP).
config.php File
define('DB_USERNAME', 'user');
define('DB_PASSWORD', 'pass');
define('DB_HOST', 'localhost');
define('DB_NAME', 'db_name');
DbConnect.php
function connect() {
include_once dirname(__FILE__) . '/Config.php';
// Connecting to mysql database
$this->conn = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
// Check for database connection error
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
/* change character set to utf8 */
if (!$this->conn->set_charset("utf8")) {
echo "Error loading character set utf8: " . $this->conn->error;
}
// returing connection resource
return $this->conn;
}
Any help is welcome!