• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • Last Modified:

Apache2 reboot breaks a .php file

bitnami
moodle-2.2.2

linux-x64-ubuntu-10.04


I am using a bitnami Moodle stack image on an instance at Amazon Web Services under EC2. I don't know whether that is relevant or not.

Anyway, there is a configuration file config.php in my web application that holds the name of the wwwroot, and one of the first things I do when I have booted the instance is update this line, then restart httpd service.

After that, the web application it works just fine. It is 100% up and running. That is, until I reboot the instance. Then the config.php files is broken.

On reboot, something is trying to write to that file. It's trying to set itself back to the previous URL, but it's not succeeding! The result is that only half the original line appears - the rest is truncated, resulting in a missing apostrophy and semi-colon, which of course breaks the rest of the code.   It doesn't matter what I do, something is re-writing the .php file on reboot. I've asked over on the Bitnami forums but there are not many people there, and have had no repsonses so far. So I am writing this on the off chance that someone who may recognise this issue and respond accordingly.

Incidently, if I re-edit to config.php file to what it should be, everything's alright again.

Since this is happening at boot time, presumably there is a boot script somewhere that's doing it. Where might I look?

/jason
0
Jason210
Asked:
Jason210
  • 2
  • 2
1 Solution
 
Sudaraka WijesingheWeb Application ProgrammerCommented:
Does that mean your config.php get reverted back to it's default state? If so, make sure you are not keeping it on a instance storage that gets wiped out on reboot.
Other thing to check would be the boot scripts as you mentioned, In general boot scripts should not alter the application configurations, but who know what those AMIs are designed to do.

One "not very good" solution would be to create your own boot script to fix the typo on boot, but better to fix the problem and fix it permanently.

Please share what you find out and I will see I can help you more with the issue.
0
 
Jason210Author Commented:
Thanks. I can tell you that the instance is EBS backed so and changes made to files should be preserved.

I think the Bitnami AMI is designed to configure this string in the config.php file:

$CFG->wwwroot =

because when you have successfuly set up the AMI and booted the instance this string reads:

$CFG->wwwroot = 'http://ec2-176-34-100-188.eu-west-1.compute.amazonaws.com';

That's the DNS name of the server. Clearly an automated process adds that information. After customising this so that it had my domain name in it, it looked something like this (only with my real domain name which will remain undisclosed):

$CFG->wwwroot = 'http://www.mydomain.com';

Of course the apache httpd.conf also needed updating to reflect the new location of the default index page, to bypass the Bitnami splash screen. All these changes were duly carried out, and the Moodle site worked perfectly.....until I rebooted the instance. Then for some reason, something tried to write to the config.php file in an attempt to restore the original $CFG->wwwroot, but ended up doing this:

$CFG->wwwroot = 'http://ec2-176-34-100-188.eu-west-1.compute.amazonaws.com

As you can see it is missing an apostrophy and a semi-colon, and thus the entire config.php file was broken and the website cratered with a 500 error. Adding the apostrophy and the semi-colon fixed the issue, but only until the next reboot, when the same thing happens again! So it's not really reverting to its default state as such.

While its nice to have the config.php file fill in automatically, it is no good if you can't over-ride those settings; and not is it fun to have to edit the config.php file after every reboot. Also it's worrying to not know what else the Bitnami image might be changing, so I'd really like to find out what is making these changes. Users should have access to the file that carries out these changes.
0
 
Sudaraka WijesingheWeb Application ProgrammerCommented:
According to http://wiki.bitnami.org/Applications/BitNami_Moodle#How_to_change_the_default_URL.3f
/opt/bitnami/apps/moodle/updateip seem to be the culprit, try removing/renaming that script as they suggest
0
 
Jason210Author Commented:
Thanks. You know, I thought I'd read through that section thoroughly but I'd missed that last sentence about updateip.

Well done!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now