Hi All,
I'm new to PHP. I've started service apache2 and put a testphp.php file in its webroot directory with the following content


But when I want to see the result in the browser, the browser opens the source file instead of showing the contents of PHP language specification.
Greatest Thanks for anybody who helps me.

5 Years
Discussion Span
Last Post by diafol

You confirmed that Apache is actually running?

Did you install XAMPP? Did you get the default page? This is in .../htdocs/ directory right?

Check your Apache files, you should have something like the following:

At the end of - C:\xampp\apache\conf\extra\httpd-vhosts.conf

NameVirtualHost *:80
<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs"
   ServerName localhost

At the end of - C:\Windows\System32\drivers\etc\hosts       localhost
::1             localhost

This is assuming you're on Windows.

Edited by diafol


Ontop of what diafol has said, make sure the file format is actually a .PHP file.

Some text editors have it set automatically to .txt or .html so even if you call it, 'testphp.php' it is actually calling it 'testphp.php.html'


Do as suggested above, otherwise, it appears to me that you maybe using an ubuntu? or any linux derivs ? How did you install your server? conical or command line?

Let me know if it is Linux distros... that should be an easy fix...

sudo :)....

Edited by veedeoo: info added


Thanks everybody,
The problem has been resolved. Was there The abrasion that apache2 was not actually started. I installed a Wamp server and set the port to 78 (because 80 was busy). After all I gave permission by turning "deny from all" to "allow from all" in httpd.conf. Now I can code php and enjoy it. I hope you enjoy coding, too.
Warmest Regards, Parsa


The abrasion that apache2 was not actually started

Yep, that'll do it. :)
Glad you came back and let us know.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.