Web page suddenly returning PHP source code?

After many years of working fine I came down one morning to the iPad displaying a page of PHP text instead of the normal Solar dashboard I have up. I’ve logged in to the Pi, rebooted, checked disk space and that the emonhub and apache2 services are running.

The text that is displayed begins:

<?php /* All Emoncms code is released under the GNU Affero General Public License. See COPYRIGHT.txt and LICENSE.txt. --------------------------------------------------------------------- Emoncms - open source energy visualisation Part of the OpenEnergyMonitor project: http://openenergymonitor.org */

…so is from the redirected page in the /var/www/emoncms folder. Looking at the emoncms logs, data is still being generated so I think it’s just a web page problem…

Any help please?

Hello @MarkHanlon, that’s strange, I haven’t seen this before, does this affect all pages? It sounds like a php problem, can you check and perhaps copy a part of the result of /var/log/apache2/error.log here?

Have you got a recent backup? Odd things happening are often the precursor to SD card failure.

April 2018 was the last backup I could find :frowning: One of those things always near the top of the list to do…

OK, I’ll take a look from home tonight at the log, and also try some other pages.

Suggest first thing is to attempt to get a backup. If you can just sftp or use WinSCP and get the data files and settings then try the manual backup process to export the database.

Avoid rebooting as I think this may accelerate the card failure if that is indeed what is happening.

How long has the card been running?

Nothing at all in the error log. I accessed the page on the 16th (again just returning PHP home page text) and nothing in the error log at all for the 16th.

[Mon Jan 14 19:17:35.115865 2019] [mpm_prefork:notice] [pid 1297] AH00163: Apache/2.4.10 (Raspbian) configured – resuming normal operations
[Mon Jan 14 19:17:35.116135 2019] [core:notice] [pid 1297] AH00094: Command line: ‘/usr/sbin/apache2’
[Mon Jan 14 23:31:17.203844 2019] [mpm_prefork:notice] [pid 1297] AH00171: Graceful restart requested, doing restart
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
[Mon Jan 14 23:31:17.220378 2019] [mpm_prefork:notice] [pid 1297] AH00163: Apache/2.4.10 (Raspbian) configured – resuming normal operations
[Mon Jan 14 23:31:17.220404 2019] [core:notice] [pid 1297] AH00094: Command line: ‘/usr/sbin/apache2’
[Tue Jan 15 11:55:20.829393 2019] [authz_core:error] [pid 7790] [client 118.24.36.103:30113] AH01630: client denied by server configuration: /var/www/html/.php
[Tue Jan 15 21:51:12.256765 2019] [authz_core:error] [pid 17398] [client 211.149.205.125:35767] AH01630: client denied by server configuration: /var/www/html/.php

It really does look as though PHP has failed. If I navigate to http://-pi address-/emoncms/test.php I get:

<?php

class Test extends PHPUnit_Framework_TestCase
{
	public function testOnePlusOne() {
		$this->assertEquals(1+1, 2);
  	}
}

?>

What exactly should I back up to be sure of getting everything? Is there a guide for backup and restore from the command line?

Thanks all,

Mark

This looks like a good clue, is there any chance that you modified apache settings? or ran an upgrade?
There are quite a few google results for the error that suggest modifications to apache settings to fix. e.g: How to Fix Apache AH01630 Client Denied by Server Configuration Error But I havent seen it before here. Is your Pi running the emonSD image or is it a custom build?

It’s the emonSD image (can’t remember the version but it’s old and I haven’t upgraded in a long time). And it just stopped working one day when I hadn’t touched it. I must admit I thought that error was just a block of a potential attacker but maybe it is indeed relevant. I’ll do some reading… Thanks.

Sounds like a dying SD card to me then.