GN Latest News

How do I recover from a corrupted Apache Template?

There are currently 34 “Frequently Asked Questions”
Post Reply
Rob Swan
Site Admin
Posts: 73
Joined: Tue Oct 31, 2017 3:03 pm
Location: UK
Contact:

How do I recover from a corrupted Apache Template?

Post by Rob Swan »

The situation is this, you have edited one of the apache templates from the control panel, and now you cannot see any of the webpages on your server including the control panel.

The reason the sever appears to be dead is that you must of made a mistake whilst editing whatever template you have edited, the Apache 2 service will not run if there is a syntax error in one or more of the templates, unfortunately Apache 2 is not very forgiving.

The solution is to restore the template to its default.

Now the problem is that in order to restore the default template we have to gain access to the control panel.

The easiest way to do this is to temporally tell Apache 2 not to include the EHCP templates.

Now this procedure is easier than you may think, in 1 or 2% of cases’ it does not work, and to be honest I don’t understand why, but be reassured the chances are it will work for you.

Despite the fact the Apache 2 is obviously not running, that does not affect us being able to access the server VIA Putty as it uses a completely different service.

So let’s do this….. (only if your server is not working of course).

Log on to your server using Putty and issue this command.

sudo vi /etc/apache2/apache2.conf

Scroll down until you see the EHCP template section.

It will look like this.

Image

All we need to do now it to temporally comment out the offending template include commands.

To do this we need to put a # at the beginning of each of the lines for EHCP that start with Include.

So press I for insert, and comment out all of the lines so it looks like this.

Image

Save the changes and exit the editor (Esc, :w (enter) :q (enter)

At this point we could just try and start the apache service, but I don’t like to do things by half so, reboot your server with the normal command.

sudo shutdown -r now

When your server has had chance to restart you will not be able to access anything from your domain names, so we need to access it by your IP.

So in your browser and go to

https://123.123.123.123/ehcp (replace 123.123.123.123 will your local or public IP address)

You should now see your control panel login screen (you may get https browser errors, which you need to add an exception for within your browser, as we had to do when you first installed your server)

Please login.

Next within your CP navigate to which ever template you edited when Apache died on you, and click Revert to Default.

If you are not sure which one it is, just do them all!

When you see the confirmation message, log out of your CP.

Now go back into Putty, and open the same file again with this command (the same as before)

sudo vi /etc/apache2/apache2.conf

Press I for insert and then very carefully delete each of the # signs we put in before so the file now looks like this again.

Image

Save the changes and exit the editor (Esc, :w (enter) :q (enter)

Now issue this command.

sudo service apache2 stop

Then this on.

sudo service apache2 start

Now test your web pages (you may have to hit the refresh button on your browser)

Assuming the correct templates where reverted back to default that is it, all fixed!

If apache will not start or your webpages are still unavailable, maybe a re-install may be in order.

Finally if your change to the template was important (for example the update on this site to the global template) now you can try again.
Post Reply