Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm a complete beginner at this, but I've set up an EC2 server and I'm trying to develop a simple php-mysql based website.

I've managed to get apache2 running and I've got a domain pointed to the server. I'm trying to set up a very simple php script to attach to a database. The following script runs perfectly well when I use the command line php simple_script.php


echo "Hello\n";

$con = mysql_connect("localhost","james","<password>");
echo "Connected\n";

However, when I go to www.myurl.com/simple_script.php I only see the line "Hello". Any help would be gratefully received!

share|improve this question
Your question is off topic for Serverfault because it appears to relate programming. It may be on topic for StackOverflow but please search their site for similar questions that may already have the answer you're looking for. –  Dennis Kaarsemaker Feb 7 '13 at 22:24
OK, I'll hava a look on there, I wasn't sure if it was an apache2 configuration thing that would be more appropriate here or a programming problem. –  Kells1986 Feb 7 '13 at 22:39
I am not sure but I think when you run script locally it runs as your logged in user privileges but when executed from web it is executed as www-data user, am not sure what effect will this have on MySQL connectivity or whether it would have any affect at all but this can be a good investigation start point. –  APZ Feb 7 '13 at 22:42
Check the apache error log for hints on what to do next –  kormoc Feb 8 '13 at 0:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.