Amazon EC2 Linux RM无法从php脚本连接到RDS MYSQL

I have an amazon EC2 instance (redhat linux ) and a RDS (mysql 5.5 ). After stop /start EC2 instance. EC2's ip was changed and cannt connect RDS anymore. I can successfully connect RDS instance from command line. However, it is unable to connect from php script and give me this warning. PHP Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on 'applicantdb.xr3x2xcale.eu-west-1.rds' (13)

It is working fine from my localhost and I can connect to localhost. It is really annoying and if somebody knows the solution. Please help me and I do really appreciate it.

You need to in your RDS Security group make sure that your Amazon EC2 security profile has access.

enter image description here

Thanks layke , the problem solved

The solution was

It restricts Apache remote database connection as default. So our scripts work in command line (# php sqltest.php), and mysql can connect to server but when Apache is involved (calling a php script as web page) then it doesn't work.

Setting: setsebool -P httpd_can_network_connect=1