I want to start learning PHP, so I installed Apache2, MySQL and PHP5 on my Ubuntu 10.10 today. For some reason, when I try to open a file other than index.html from the default directory /var/www/, I either get a 404 error or I get a prompt to download the php file. I googl’d all over and I can’t find a solution.
When I do http://localhost/index.html, it works, and displays whatever I write in index.html. When I change /index.html to /test.php, I get an error saying “The requested URL /test.php was not found on this server”.
When I try /var/www/index.html or file:///var/www/index.html, again, index.html appears although it appears differently. When opened with http://localhost/index.html I only get “It works!”, but with /var/www/index.html I get “It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.”
And then when I change /var/www/index.html to /test.php, I get a prompt to download test.php.
In my .conf files, the default directory is set to /var/www/, so this is very weird.
Edit:
Did some checking, and it seems that when I run http://localhost it’s set to a directory in the httpd directory. I tried putting my test.php file there, and still I’m getting 404. But when I write the full path, again, I get a download prompt.
This problem is really confusing… thanks to all helpers.
Ok.. seems that I found the solution myself. For some weird reason, I have like 4 different localhost default folders. I had to search manually through each folder containing index.html and move test.php there. Eventually, I found an obscure folder somewhere in the /usr/ folder, moved test.php to there, and it worked. Apparently I have like 4 different versions for each .conf file, and each one states a different thing. Only one of them works.
Phew. What a relief.