Solved

Apache2 reboot breaks a .php file

Posted on 2012-04-01
4
650 Views
Last Modified: 2013-11-13
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
Comment
Question by:Jason210
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
ID: 37794960
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
 
LVL 11

Author Comment

by:Jason210
ID: 37795005
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
 
LVL 18

Accepted Solution

by:
Sudaraka Wijesinghe earned 500 total points
ID: 37795261
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
 
LVL 11

Author Comment

by:Jason210
ID: 37795274
Thanks. You know, I thought I'd read through that section thoroughly but I'd missed that last sentence about updateip.

Well done!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now