500 error upgrading Plugins after upgrade/move

500 error upgrading Plugins after upgrade/move

by Eric Krebill -
Number of replies: 9

Full information:


I had to move Moodle to a new Ubuntu server.  The old server corrupted and I had been temporarily running Moodle from an Instant VM Recovery.  The new server is the same OS, same version as the old one.  While I had to move anyway, I figured it was a good time to upgrade Moodle.  Because I am patently insane, I decided to also move to a new database server.  The old mySQL database was on Windows (not my idea), but the new one is on Ubuntu.  I host 7 different instances of Moodle on this server.  Each school district used to have their own and now I host them all on this server.  So here's what I did:


Old Version - 2.5.2

Intermediate Version - 2.9.5

New version - 3.0.2


So, here's basically what I did.


1 - Move files from old server to new server and make sure everything works.

2 - Move database to new server (export/import via command line).

3 - Change config.php file and make sure everything works.

4 - Backup config.php file and empty Moodle directory.

5 - Copy in config.php file and Moodle 2.9.5 files.

6 - Run upgrade from CLI.  Check to make sure everything works.

7 - Empty Moodle directory.

8 - Copy in config.php file and Moodle 3.0.2 files.

9 - Run upgrade from CLI.  Check to make sure everything works.


Moodle runs great.  It's significantly faster than before (login time went from ~45 seconds to right around ~2 seconds).  I can get to all the courses, I can add users and change themes.  From the outside, everything is fantastic.  Truly better than I could have expected.


Unfortunately, on the admin side not everything is as nice as it seems on the surface.  I'm nearly certain I have something wrong with the server for this because I have the exact same error for each of my Moodle instances.  When I try to go to the Site Administration > Notifications link, it either comes up blank, or with a 500 error.  Same if I go to the Plugins and try to do an upgrade or change to any plugins.  Here are the errors being logged by Apache.


[Sun Apr 10 21:37:58.083892 2016] [:error] [pid 28356] [client 207.46.13.105:26737] PHP Fatal error:  Cannot redeclare class moodle_database in /var/www/html/moodle_maisd_net/macc/lib/dml/moodle_database.php on line 63

[Sun Apr 10 21:48:47.670494 2016] [:error] [pid 28354] [client 180.76.15.21:44013] PHP Fatal error:  Cannot redeclare class moodle_recordset in /var/www/html/moodle_maisd_net/macc/lib/dml/moodle_recordset.php on line 37

[Sun Apr 10 22:31:27.441666 2016] [:error] [pid 28580] [client 23.236.246.2:58387] PHP Fatal error:  Cannot redeclare class moodle_database in /var/www/html/moodle_maisd_net/macc/lib/dml/moodle_database.php on line 63, referer: http://moodle.maisd.net/

[Mon Apr 11 12:49:26.524910 2016] [:error] [pid 889] [client 96.36.52.2:45014] Default exception handler: Coding error detected, it must be fixed by a programmer: No further information available for this branch Debug: \nError code: codingerror\n* line 128 of /lib/ajax/getnavbranch.php: coding_exception thrown\n, referer: http://moodle.maisd.net/greenville/course/view.php?id=111


If I turn debugging on in Moodle (I can get to that page), I get this:


Fatal error: Cannot redeclare class lesson in /var/www/html/moodle_maisd_net/macc/mod/lesson/locallib.php on line 0


So my question is this, what did I miss?  Did I forget to install something for PHP?  


Any help is greatly appreciated.

Average of ratings: -
In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Eric Krebill -

So I tried a fresh install of Moodle today, just to see if it was a server problem.  It is definitely something wrong with the server, but I don't know what.  I got the latest version of Moodle, installed it, and it didn't even make it through the install before it failed.  It just kept stopping through those install pages.  No error, just stopped.  I had to refresh the page after a while to make it come up again, and each time it came up to the next step.  When I finally got through the install, boom, 500 error.


I've sifted through every page I can find on Moodle prerequisites and installed every package I can find.  I really need help here, so anyone has any ideas, I'd greatly appreciate it.

In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

So everything else is working except the Notifications page and the plugins upgrades?

Both these pages are reaching out to moodle.org for information - normally these errors show up when your server has some sort of firewall/security protection going on that is stopping the communication between your server and moodle.org.

I would start there...

In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Ken Task -
Picture of Particularly helpful Moodlers

Uhhh ... missing some info .... running apache as a mod or with php-fmp or with fast-cgi?

Obviously everything didn't work on the first upgrade from 2.5.x to 2.9.x.  Did you check admin pages/links at the 2.9.x stage?

Uhhhh ... /greenville/user/administrator on policy page ... Moodle doesn't use relative addressing for anything.

What do you have for each sites:

$CFG->dirroot

You had to edit config.php files for each site ... omit a ';' at the end of each config line?   missing a '/' trailing slash for paths lines?   config.php files are at least readable by all.   Using 'ticks' or "quotes" around variables?

When admin'ing multiple sites on same domain but different subdirs always thought it best to have a different cookie setting on the server.   Cookie for 'greenville', as an example, would have 'GRNVL' as cookie prefix.   Affected Admin level users mostly.  On workstation, clear all cookies for the server in question and clear browser caches ... assume you have used more than one browser in trouble shooting this.

And all files/folders in each site has correct ownerships/permissions ... moving files round and editing config's usually done as root and I often forget to chown ... until a get a blank page.

Assume you are running opache as well.   With the number of sites running, wonder if opcache has enough memory allocated to it to handle opcaching all the sites.

Wonder if purging caches might help ... think I'd do that manually this time.  

Any other/additional config to apache/php ... Shoshin or other additional protection?

'spriit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: 500 error upgrading Plugins after upgrade/move

by Eric Krebill -

Thanks for your suggestion Emma.  I pinged and did a wget from moodle.org and was able to successfully reach out.  

Thanks also to Ken for taking the time so far.  The server is Ubuntu 14 with full Apache2 and PHP 5.5.9 installed.

I did check the admin pages at the 2.9 stage.  They didn't work then either.

I uploaded my config.php to dropbox: https://www.dropbox.com/s/mfcblupd4gpffuv/config.txt?dl=0  

The only edits I did to the config.php files was in nano and didn't leave any unnecessary characters.  

I will look into changing the cookies for the future, but to answer your question, I did try different browsers and used incognito mode to ensure it wasn't a cache issue.  I've also connected from multiple different network connections to be sure that isn't an issue.

When I copy in the files from the unzipped directory, I use rsync -rva so it keeps the correct permissions and ownership.  However just to test I re-ran chown and chmod for the entire directory and still have the same problems.

I am running opcache as instructed in the Moodle manuals.  I tried to account for running multiple sites on the server, although not for every one.  I host 7 different moodle instances on this server, but only 2 of them get used regularly, so I accounted for those 2 with a little padding.

I purged the cache before I moved the files to the new server so that it was less data to move.  Also, no additional config to apache/php for protection purposes.

In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

So you can get out to Moodle but can Moodle talk back to you? I still think this is a firewall issue. I have run into this before. Unfortunately the network guy that fixed it just left so I cannot find it what he did!

In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Ken Task -
Picture of Particularly helpful Moodlers

Config file checks out ... but still ... running apache under mod or a fastcgi or under php-fmp?

So ... and just so I understand ... the 2.5.2 versions were simply transferred to another server ... and setup.   Those checked out without error.    You did a 'hyperjump' from 2.5 to 2.9 and then the admin links didn't work.    Well, then **stop** ... going to 3.x anything ain't gonna fix what should be working in 2.9.x.

Strongly suggest just getting the 2.5.2 up and running in greenville - as is.   Check admin links there ... should work ... no problems.

Suggest you might look into using git.

the greeenville diretory is the xferred 2.5.2 code ... at same level use git to acquire moodle code to a greenvillegit directory.    Copy (rp) any *addon*  mod/block/theme from greenville code to greenvillegit code (not the core code - just the addon stuff).

Clone the greenville DB to a greenvillegit DB.   Clone the greenville data directory to a greenvillegitdata directory.

Set greenvillegit code to the 2.5.branch ... that would result in a slight upgrade to 2.5.highest.  

In greedvillegit code copy config-dist.php to config.php and manually make the necessary changes to point to all greenvillegit stuff.   Check permissions/ownerships, etc..

Should be able to point browser to http://site/greenvillegit/ and have everything work.  Including the admin links after doing a search/replace for http://site/greenville/ replace with http://site/greenvillegit/

If that works ok, then we could talk about upgrading greenvillegit to 2.6 then to 2.7 then to 2.8 then to 2.9 then to 3.highest.   Yes, it's a 'march' not a hyperjump.   March via git isn't all that painful ... most of the time one is watching screen and waiting.   After each step up, site backup of code and DB, then check ... admin links work?   If so, next version up via git. .... wash, rinse, repeat.

Also ... new DB server?   In clip of config ... didn't show 'localhost' so it's another box?  A dedicated DB box?

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Ken Task -
Picture of Particularly helpful Moodlers

That last error happened to the greenville site

line 128 of /lib/ajax/getnavbranch.php

// Prepare an XML converter for the branch
$converter->set_expandable($navigation->get_expandable());

while constructing a navigation expansion thang of some sort.   What additional plugins do you have in the greenville site that are NOT core?   And, what is the theme for greenville?

We've not really talked about php and extensions loaded ... so:

php -m

you should see supports for xml

php -i

have /etc/php.d/json.ini php-json?

'spirit of sharing', Ken



Average of ratings: Useful (1)
In reply to Eric Krebill

Re: 500 error upgrading Plugins after upgrade/move

by Ken Task -
Picture of Particularly helpful Moodlers

Just to follow up ...

issue related to installation of xCache on Linux.   Once removed and web service restarted, no more 'weird errors' and site accessible.   Cleaned up as well ... former admin (not Eric) evidently didn't know now to remove mods properly and assignments hadn't been upgraded (that also has been fixed).

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: 500 error upgrading Plugins after upgrade/move

by john attwood -

mine turned out that when I copied over the config.php it changed the permissions to 640 as  opposed to 644. I changed them to 644 and away it went on the new upgrade.