Moodle site migrated on a new VPS and not loading anymore

Moodle site migrated on a new VPS and not loading anymore

Alex B發表於
Number of replies: 7

I have migrated my Moodle 3.8 site to a new hosting (VPS), and after a bunch of tries it still doesn't load when I try in the browser to load the website and I am stuck at this stage, if anyone has any experience with this would be appreciated.

The previous VPS config: ubuntu 18.04, apache, php7.2, mariadb 10.1.48.

Backed up moodle folder, moodledata, sql, deployed and restored the same files on the new server.

The new VPS was new, no config. Now the config is a bit different: ubuntu 22.04, apache, php8.1.2, mariadb 10.6.16.

Initially after all the setup, copying the moodle files and restoring db, when loading the website/moodle in the browser I would get this error "Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting." 

I have changed the permissions trying to make it work:

sudo chown -R www-data:www-data /var/www/moodle

sudo chmod -R 755 /var/www/moodle

sudo chown -R www-data:www-data /var/www/moodledata

sudo chmod -R 777 /var/www/moodledata

but for some reason (because of this or other changes I kept doing to the server, now the only result I get when loading the site in my browser is "This page isn’t working [moodle.com] is currently unable to handle this request. HTTP ERROR 500".

After this, I tried to replace index.php with a simple phpinfo(); to see if Apache etc. still working fine when I load the website. Another check - I ran in my browser the website with index.php containing just a dummy connection to the sql db and sql connection is ok as well.

I am running out of ideas. Any suggestions please? Thanks!

評比平均分數: -
In reply to Alex B

Re: Moodle site migrated on a new VPS and not loading anymore

Leon Stringer發表於
Core developers的相片 Particularly helpful Moodlers的相片

HTTP ERROR 500 means internal server error. May your server's error logs contains something to help identify the cause.

But if your site's source code is Moodle 3.8 and you have PHP 8.1 on the new VPS then that won't work. Moodle 3.8 works with PHP 7.2, 7.3 or 7.4 only. And there's no version of Moodle that both supports PHP 8.1 (the earliest is Moodle 4.1) and can be upgraded from Moodle 3.8 (the last was Moodle 4.0).

If you want to host on a VPS with PHP 8.1, you'll need to upgrade to Moodle 4.1 (or later) which will involve upgrading to Moodle 4.0 first, and Moodle 4.0 requires PHP 7.3, 7.4 or 8.0. Maybe you can set up a VM temporarily for this interim upgrade, then migrate that to your VPS.

This table shows which versions of Moodle work with which versions of PHP, and which Moodle versions they can be upgraded from (the From rel. column).

評比平均分數:Useful (1)
In reply to Leon Stringer

Re: Moodle site migrated on a new VPS and not loading anymore

Alex B發表於
THANK YOU!!!
It worked! I just disabled php8.1 and installed 7.2 , and some additional changes in php.ini to enable mysqli and installed another package too in ssh sudo apt install php7.2-mysql
In reply to Alex B

Re: Moodle site migrated on a new VPS and not loading anymore

Leon Stringer發表於
Core developers的相片 Particularly helpful Moodlers的相片

That's good news.

Moodle 3.8 has been unsupported for 3 years so ideally you should plan to upgrade to a supported version.

評比平均分數:Useful (1)
In reply to Leon Stringer

Re: Moodle site migrated on a new VPS and not loading anymore

Alex B發表於
Thank you. That's a sensible advice.
Actually I have Moodle 3.8.3. So first I need to upgrade to 4.0.12 and then to 4.3.4?
In reply to Alex B

Re: Moodle site migrated on a new VPS and not loading anymore

Leon Stringer發表於
Core developers的相片 Particularly helpful Moodlers的相片

Yes you need to upgrade to Moodle 4.0 first, then Moodle 4.3 if that's your target. But you could upgrade to Moodle 4.1, the current long-term support (LTS) version, as this has support for six months after 4.3 (8 December 2025 for 4.1 versus 21 April 2025 for 4.3). It depends on whether you want the stability of the LTS version or the latest features of a more recent version.

評比平均分數:Useful (1)
In reply to Alex B

Re: Moodle site migrated on a new VPS and not loading anymore

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
As a long jump from 3.8 to 4.3 is not supported, you have a couple of options for the "hop(s)". I advocate the "LTS route", > 3.9 LTS final > 4.1 LTS current > 4.3 current. LTS, since they lived long, are better tested, i.e. more "stable". You can figure out your options from this chart: http://www.syndrega.ch/blog/#php-and-dbms-compatibility-of-major-moodle-releases. There's another reason, why you should take time for the transition in to Moodle 4. The look and feel changed so much, you and your users might get surprised. 眨眼

Don't forget the additional plug-ins. They usually give more trouble. Go to each page in the plug-in database and check whether they are maintained, viz. have versions compatible with your target Moodle version.

評比平均分數:Useful (1)
In reply to Alex B

Re: Moodle site migrated on a new VPS and not loading anymore

Ken Task發表於
Particularly helpful Moodlers的相片

Just a reminder now that you are on a VPS ... setup of cron job is outside of moodle but very important.

Since you have CLI access to your VPS, suggest setting up cron job then running it from CLI manually from code/admin/cli/

There are many settings to a moodle - also suggest running from admin/cli/ the cfg.php like so:

php cfg.php > allsettings.txt

then checking out allsettings.txt file for config changes you might need.

And since your DB changed ... run the check_database_schema.php script.

And since you are looking at a march of your moodle upwards, make a full site backup prior to any march upwards.

'SoS', Ken

評比平均分數:Useful (1)