0

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

<?php
phpinfo();
?>

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.

4
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by diafol
1

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
</VirtualHost>

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

127.0.0.1       localhost
::1             localhost

This is assuming you're on Windows.

Edited by diafol

1

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'

0

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

0

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

0

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.