I am trying the following script:
<?php
mysql_connect("inspectlettest.ce0ohcvwmist.us-east-1.rds.amazonaws.com", "username", "password") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
The web server is strangely returning a 500 Internal Server Error.
I can connect to the mysql server via terminal from the instance just fine.
Any ideas?
When you get an internal server error when executing a php script, your first step should be to get more information about this error. On Ubuntu, you can check following apache log file:
/var/log/apache2/error.log
It is possible that it will say something like that:
[...] PHP Fatal error: Call to undefined function mysql_connect() in [...]
If you see it, it is possible that some required packages are not installed on your system. If I remember correctly, you need at least mysql-client
and php-mysql
packages. Restarting the apache server may also be necessary:
$ sudo apt-get install mysql-client
$ sudo apt-get install php-mysql
$ sudo /etc/init.d/apache2 restart
If your error message is different, please add it to the question, it will make helping you easier.
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