EC2 Ubuntu mysql_connect 函数导致 500 内部服务器错误
我正在尝试以下脚本:
<?php
mysql_connect("inspectlettest.ce0ohcvwmist.us-east-1.rds.amazonaws.com", "username", "password") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
Web 服务器奇怪地返回 500 内部服务器错误。
我可以通过终端从实例连接到 mysql 服务器。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在执行 php 脚本时遇到内部服务器错误时,您的第一步应该是获取有关此错误的更多信息。在 Ubuntu 上,您可以检查以下 apache 日志文件:
它可能会说这样的话:
如果您看到它,则可能您的系统上未安装某些所需的软件包。如果我没记错的话,你至少需要
mysql-client
和php-mysql
软件包。可能还需要重新启动 apache 服务器:如果您的错误消息不同,请将其添加到问题中,这将使您更容易获得帮助。
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:
It is possible that it will say something like that:
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
andphp-mysql
packages. Restarting the apache server may also be necessary:If your error message is different, please add it to the question, it will make helping you easier.