MIgrating Moodle from Ubuntu to REHL 7

MIgrating Moodle from Ubuntu to REHL 7

by Stephan Tedesco -
Number of replies: 8

We are trying to migrate our current Moodle 2.9.1 installation from our Ubuntu server to the new REHL 7.

We took the following steps:

  1. Copied the directories

old-/var/www/moodledata new-/data/www/moodledata

old-/var/www/html/moodle

new-/data/www/html/moodle

  1. Made MySQL-Dump of the database.
  2. Made the same Apache configuration as on the Ubuntu

We made an redirect from the old http://moodlesite.com to https://moodlesite.com and got:

Incorrect access detected, this server may be accessed only through http://moodlesite.comaddress, sorry. Please notify server administrator.

Then followed these steps:

Change the following file: /home/xxxxxx/public_html/moodle/lib/setuplib.php
Change -  setuplib.php
Redirect ($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
for
Redirect ($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 0);

Now when you access the link, Moodle redirects immediately to the www.<your registered domain> without the warning message.

Another solution is to make changes in .htaccess file

***************************************************************
suphp_configpath /home/myroot/public_html/php.ini
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.domainname.com [nc]
rewriterule ^(.*)$ http://domainname.com/$1 [r=301,nc]
 i.e. replace the myhost.com  with your domain name
***************************************************************

...and got HTTP Error 500, checked the Apache permissions:

[root@srv24 html]# pwd
/data/www/html
[root@srv24 html]# chown -R apache:apache moodle/
[root@srv24 html]# chown -R apache:apache ../moodledata/
[root@srv24 html]# chmod -R 755 moodle/
[root@srv24 html]# chmod -R 755 ../moodledata/
[root@srv24 html]# systemctl restart httpd.service
[root@srv24 html]# apachectl configtest
Syntax OK

But the error still remains.

What have we missed?


Average of ratings: -
In reply to Stephan Tedesco

Re: MIgrating Moodle from Ubuntu to REHL 7

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

It all started to go horribly wrong round about "Then followed these steps..."

Firstly, restore Moodle core code to how it 'left the factory' wink

Why don't you just change your DNS so that the URL is pointed to the correct server? You cannot have (effectively) two different 'wwwroot' settings for Moodle. Hacking the code to (try to) work around it is not the answer. 

In reply to Stephan Tedesco

Re: MIgrating Moodle from Ubuntu to REHL 7

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

All you should have had to do is update the moodle/config.php file and update the site url in that file.

You will also need to run replace.php to update the database with the new url.  

In reply to Emma Richardson

Re: MIgrating Moodle from Ubuntu to REHL 7

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ye-es... but I suspect the OP's root problem is that he has tried to redirect the URL of the old server to the new one rather than updating DNS. I imagine he/she is trying not to change the URL of his site. 

In reply to Howard Miller

Re: MIgrating Moodle from Ubuntu to REHL 7

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

But he is changing from http to https - so that is a change according to Moodle.

In reply to Stephan Tedesco

Re: MIgrating Moodle from Ubuntu to REHL 7

by Ken Task -
Picture of Particularly helpful Moodlers

For one ... this shouldn't be all that difficult, but if using something not defined in default httpd.conf of a CentOS 7 boxen, could bite ya.  CentOS 7 runs apache more like Ubuntu does now (Linux Standards Base decision, I guess).  

Is this also moving from standalone (Ubuntu) to remotely hosted VPS (CentOS 7)?

Don't know why one would use /home/whatever/public_html/ - which is an Apache user 'jail' for lack of better description. Why shouldn't one be using /var/www/?   Apache on CentOS 7 should know bout that already ... even if on remotely hosted VPS (self-managed) - I would think.

And if running something like suPHP on CentOS 7 which wasn't present on the Ubuntu box then that's also a tweak that needs to be addressed, me thinks ...  I see an suPHP ... if I re-call, suPHP doesn't like things writable by a group.

Apache config syntax is correct, doesn't really mean Apache is configured correctly, though. There is an option for apachectl to check virtual server config as well.

Using Apache Virts?    What's default for port :443?  and for port :80?

Some two cent thoughts.

'spirit of sharing', Ken



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

Re: MIgrating Moodle from Ubuntu to REHL 7

by Stephan Tedesco -

Thank you all for the feedback! I will check everything one more time and try to fix the issue and reply with solution or (hopefully not) more problems. 


Regards, 

S.