开发者

EC2 Ubuntu mysql_connect function causing 500 Internal Server Error

开发者 https://www.devze.com 2023-03-09 22:22 出处:网络
I am trying the following script: <?php mysql_connect(\"ins开发者_运维技巧pectlettest.ce0ohcvwmist.us-east-1.rds.amazonaws.com\", \"username\", \"password\") or die(mysql_error());

I am trying the following script:

<?php
 mysql_connect("ins开发者_运维技巧pectlettest.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.

0

精彩评论

暂无评论...
验证码 换一张
取 消