EC2 Wordpress Only Showing Apache Test Page After It Was Up For A Week

I woke up this morning and my AWS Linux EC2 instance running Wordpress is showing just the Apache test page. I have Wordpress installed on this site and it's been up and running for about a week or so.

Here's a few things I've done to resolve this:

  • Restarted Apache
  • Confirmed MySQL is running
  • Restarted the EC2 Instance from the AWS Management Console

Anything I missed? I'd love to save my work and show it to the world.

The URL is

Thank you for your assistance.

TessandoIT AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have you validated the WP files still exist and that MySQL has your data?

If so, it could be that your Apache config isn't set up to listen to incoming requests for that domain (or on a specific IP that changed).
Shalom CarmelCTOCommented:
Try going to
What you see is the result of an Apache misconfiguration. If you dig into the server logs or into your memory, you will find that someone did something.
Looks like php is not recognized as the script processor, and looks like your .htaccess is fubar.
Prabhin MPEngineer-TechOPSCommented:
1) your document root folder is correct.
2) Php is not properly installed or dependency issue with webserver and php files

if you want more support pls give the access, i can help u on this
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Just FYI, please do not post any access credentials here. This is a public forum. If you want 1-on-1 paid help from any of us, there is a Live help feature on this site where you're in a private chat session with an expert and can provide them the access within that chat.
TessandoIT AdministratorAuthor Commented:
Thanks Everyone - I appreciate the quick response. @Prabhin MP - I went to reinstall PHP and it's up to date. Any suggestions of how to check dependency issues with the WebServer or PHP Files?

I ask because this came out of the blue. I spun this up last week, worked on it all week even up until Saturday afternoon. When I checked it on Sunday morning, I get this PHP misconfiguration (or, I should say, the site didn't come up as expected). It's important to mention that I did no server work over the weekend, rather this "just happened". Are there any low-hanging fruit things to check from a configuration perspective? This is a very vanilla installation of Wordpress.

Thank you again.
TessandoIT AdministratorAuthor Commented:
I replaced my .htaccess folder with the standard out-of-the-box code from Wordpress and this didn't make a difference. (I backed up the .htaccess file before doing so).

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Open in new window

Any other suggestions would be helpful. Thank you.
Can you find your httpd.conf file on the shell, and then do a grep through the configs for references to PHP?  For example, let's say you have /etc/httpd.conf
and a bunch of additional configs in

On the shell, do these two commands:
grep -i "php" /etc/httpd.conf
grep -ri "php" /etc/httpd.conf.d/*

If you're not sure where to find the httpd.conf file, try these 2 commands:
locate httpd.conf

Note that if you don't have mlocate installed, that command will fail. If you're running CentOS, you can install mlocate with:
yum install mlocate

...and then run your updatedb and locate commands. (The very first time you run updatedb might take a couple minutes)

This will tell us if you have an Apache config file that doesn't have PHP installed properly (and whether or not you have multiple httpd.conf files in case there was a server reboot that happened and it resulted in Apache loading an incorrect default config file).
TessandoIT AdministratorAuthor Commented:
I found the error logs at /var/log/httpd. Doing a "tail" command (tail -f /var/log/httpd/error_log) I consistently see this coming in when I hit the home page:

[Mon Mar 05 22:43:34.978312 2018] [autoindex:error] [pid 3374] [client 7*.**7.**5.*0:56067] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

Open in new window

After doing some Google-Fu I found a solution that recommended adding 'index.php' to the httpd.conf file. I entered the following:

<IfModule dir_module>
DirectoryIndex index.html [b]index.php[/b]

Open in new window

I restarted Apache and this didn't seem to have any change to my sites. Any further suggestions would be greatly appreciated. Thanks!
TessandoIT AdministratorAuthor Commented:
@gr8gonzo Thanks for you suggestion.

I am using Amazon Linux, so the location of my httpd.conf file is at grep -i "php" /etc/httpd/conf/httpd.conf so I ran the command:

grep -i "php" /etc/httpd/conf/httpd.conf

Open in new window

and the only reference to php is the new entry I described in my last update:

DirectoryIndex index.html index.php

Open in new window

Should there be more references to PHP that you know of?
Do you have any lines in your httpd.conf that are included? Example

Include conf/extra.conf

Sometimes different distributions try to separate out different parts of the configuration to different files.

And yes, you should have more references to PHP. There are a few different ways to set up Apache to use PHP, but the more common way is with mod_php.

This is usually done with a LoadModule line, like this:
LoadModule php7_module modules/

NOTE: This is ONLY an example from one of my web servers that is running PHP 7 on Apache 2.4. Your config would have to take the version of PHP into account and the correct path to the PHP module. You can find out the path to your shared module (the .so file) by doing:

locate .so | grep -i "php"

Once that's done, then Apache will know how to load the PHP engine, but it needs to be told WHEN to do it. The simplest way is to use a SetHandler, like this:

<FilesMatch \.php$>
  SetHandler application/x-httpd-php

That tells Apache, "Whenever you come across a file that ends in .php, let it be handled by the PHP engine."

I don't know of any reason why your configuration file would have PHP working for a few days and then suddenly NOT have it without any changes. My first instinct is that you got an Apache or PHP update or something that basically overwrote your old config file with defaults, but that's REALLY strange. Most updates will not touch your config file. Is there any chance someone else is working on the same server and did something without your knowledge?
Prabhin MPEngineer-TechOPSCommented:
create file /var/www/html/info.php and add the following lines , let me know the out ,

TessandoIT AdministratorAuthor Commented:
Hey Guys. Thank you so much for your effort.


There are 2 Additional references to ".conf" in the httpd.conf file. For my own sanity I've included the line numbers:
56 Include conf.modules.d/*.conf
353 IncludeOptional conf.d/*.conf

There are 123 references to PHP using the "locate .so | grep -i "php" "command

Added to httpd.conf: (Added at line 58)
<FilesMatch \.php$>
  SetHandler application/x-httpd-php

I restarted Apache and am still getting just PHP code on the site.

@Prabhin MP

I created that file and it only shows the lines you mentioned. This can be found here:

In other words, it's still just showing PHP all around and not even giving me the version.

Thanks again. I appreciate all the effort you guys have put into this.
Prabhin MPEngineer-TechOPSCommented:
if  info.php showing only the code, then it means the there is dependency issue with the webserver and PHP
can you tell me which version of apache and php you are using?
TessandoIT AdministratorAuthor Commented:
@Prabhin MP

I'm running Amazon Linux with PHP 5.6.33 and Apache/2.4.27 (Amazon)

Hope this helps. Thank you for your assistance.
Personally I would suggest a live session with an expert at this point since you've now been down for a few days. It will likely cost some money (how much depends on the person's rate and how much time it takes them to fix the issue) but it's the quickest solution if you want the site back up asap.

If time / downtime isn't a problem, then you could certainly continue trying to debug it here.
TessandoIT AdministratorAuthor Commented:
@gr8gonzo - I'm with ya. This isn't mission critical, but I am delaying marketing tests and obviously paying for this server to be running.

What if I created another LAMP Stack (using the same directions I did before:, kept the same domain name and migrated the database and Wordpress files (e.g. wp-config, wp-settings, etc). Now, exactly how to do this, I'm not totally confident with but if I find a good recipe I should be able to follow it.

I guess I'm looking for confirmation that (1) this is Server related and not related to Wordpress itself and (2) if I was able to slipstream the databases into a new Server, it's entirely possible to migrate.

Thanks again for your help. You guys have gone above and beyond.
Ah, that's good information (the guide you used before). So if you followed that guide, you should end up with PHP 7, not PHP 5...

Now, I wouldn't suggest the 2nd LAMP stack. There's a very good chance that this is a REALLY quick fix, so building a second LAMP stack is like moving to a new home because you couldn't find the light switch in your old home.

So first, if you followed that guide, then you likely have PHP installed via the yum package manager, so let's confirm what version of PHP you really have installed. First do this:

sudo yum list installed | grep -i "php"

That should show you any packages installed that have the word "php" in them.

Normally, these packages should correspond to RPM packages, so you can double-check by doing this:

sudo rpm -qa | grep -i "php"

You should see a package in that list that looks something like this:


(the numbers might be different and there may be some extra text afterwards)

Take that line and instead of "rpm - qa", do "rpm -ql" and pass the package name to it, like this:

sudo rpm -ql <the full package name> | grep -i "\.so"

That command will list the files that come from that RPM package and the | grep -i "\.so" part will filter the output only to the lines that have ".so" in them (the .so is a Shared Object library, which is what you usually have to plug into Apache).

Ideally, you'll see something like (again, paths could be different):

Whatever comes back, just double-check to make sure that file still exists (it should), by listing it:

ls /usr/lib/ (or whatever the file / path is)

If it exists, then go into your Apache config, and find the section where all the modules are loaded. It should be a big section near the beginning that has a bunch of lines that look like:

LoadModule modulenamehere modules/

At the bottom of that list, add this line if you have PHP 7:
LoadModule php7_module /usr/lib/ (or whatever the file/path is)

...or if you have PHP 5:
LoadModule php5_module /usr/lib/ (or whatever the file/path is)

Save and restart Apache and try accessing a PHP file again via the URL.

If it's still showing code, then send me a private message and we can see if there's any chance we can knock it out in 1:1 chat (hopefully within the first 5 free minutes).

To answer your overall question about what the problem is, it's DEFINITELY not a code problem, nor a Wordpress problem, nor a database problem. Whenever you ask Apache for a PHP file and you see the PHP code contents instead, it means that Apache is treating that file like any other file and just sending you the raw contents instead of invoking the PHP engine to process the code and returning the results from that PHP engine. So it's almost guaranteed to be a matter of just telling Apache where to find PHP.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shalom CarmelCTOCommented:

There is a fair chance that your apache error logs will have a hint or two.
Look in the /etc/httpd/logs directory for a file called by default error_log. If there is a missing apache module it will be in the logs.
TessandoIT AdministratorAuthor Commented:
After confirming the version of PHP I was running (per your awesome instructions), I added this line to the Apache configuration file: LoadModule php7_module /usr/lib64/httpd/modules/

After restarting Apache and restarting MySQL, I was back in business. Thank you SO MUCH for your effort. This really had me stumped and you quickly fixed it once we established what the challenge was. Thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.