I am just now migrating an application from a standard dedicated server that I have onto AWS EC2. I have also moved the database (MySQL) onto Amazon RDS. Now I have an issue that I am pretty sure has to do with either PHP or Apache configuration.
On my dedicated server I can now reach the Amazon RDS database without a problem, but on the EC2-instance, using the exact same code I get this message:
SQLSTATE[HY000] [2003] Can't connect to MySQL server on ....................eu-west-1.rds.amazonaws.com
I can reach the db-server both from Sequel Pro on my laptop, and from PHP on my other server. I tried to put in the IP-address for the MySQL db on my other server, but same error message, so I am thinking there is some configuration either in Apache or PHP that I need to do?
It is a EC2 instance running Apache and PHP on CentOS.
Suggestions as to what configuration could be blocking this connection?
To anyone else who might have the same problem, run this in SSH, it worked for me:
setsebool -P httpd_can_network_connect=1
Tried successfully setsebool -P httpd_can_network_connect=1 on RHEL image on EC2 and it was able to connect with AWS-RDS in the same VPC.
For more information see. This is a MUST step on RHEL
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Booleans-Configuring_Booleans.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With