Hi,
I have installed an Apache server (version 2.4) on my Windows 10 computer, and then I have installed PHP and edited the configuration files to the best of my ability.
(This is my first time installing an Apache server, so I might have made a few rookie mistakes)
The problem is that PHP code inside a HTML document is not executed, instead the code is commented out.
I try to run this HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>
<?php echo "My first PHP script!";?>
</h1>
</body>
</html>
The result is a blank page.
If I use the developer mode (F12) the code looks like this, so I guess there is no surprise that the page is blank.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>
<!--
</h1>
</body>
</html>
I have tried both to run the file from the browser as a local host, http://localhost:8080, and open the file directly, but the result is the same.
However, if I run a PHP-file directly it works.
I created a file called phpinfo.php and put it in the configured root directory.
<?php
phpinfo();
?>
Then I use the following link in the browser
http://localhost:8080/phpinfo.php
The result is the PHP-info page.
This gets me a bit stumped as I am new to this and I don't know what else to configure.
I have probably missed some simple configuration, but right now I cannot think of anything else.
Does anyone know what the problem might be and a possible solution?
What I have tried:
I have tried both PHP 5.6 and PHP 7, but with the same result.
I get the same result regardless of browser, Edge, Chrome, Firefox.