Why would my webpage be displayed as plain text HTML rather than the generated webpage?

Viewed 151

I have been using Apache to host a website all last semester, but I believe some setting got changed because now when I try to access my website rather than displaying the website my HTML/PHP should generate, it just shows the plain-text HTML file (the code that I have written is what is displayed when I access localhost).

I am on a Mac running Big Sur, and I have PHP/Apache/MySQL currently on my computer and I am using MAMP to maintain it.

I have tried resetting the apache server, but still no luck. I'm not sure what I should be doing differently.

EDIT:

I do have apache configured appropriately, I have LoadModule php7_module uncommented along with the path to the php 7 folder, and I also have AddType uncommented so that it will recognize .php extensions, and I have verified that all my files that I am trying to access are in the correct format (I've been using these files for months and know that they work, nothing has changed with any of them).

EDIT 2: I changed the file extension to .html, and it rendered it as I would've expected, but with my PHP code being displayed on the page. Why would this be happening if I have 'AddType' configured properly?

1 Answers

I can't comment because my account isn't old enough, but try the following things:

  1. This happened to me a while ago, if you have comments at the start of your PHP code like this <?php*/, change it to <?php (newline) */

  2. Check your server is running on port 80, if it's not, make sure you're accessing the right port when you visit it

  3. Check there aren't multiple index files

Related