Changing Moodle server hostname?

Changing Moodle server hostname?

by David M -
Number of replies: 2

Is it [easily/safely] possible to change the hostname of a Moodle server?

I'm an overworked sysadmin and Moodle server maintenance forms only a small part of my job.

For live internal use we install a new Moodle server (with a new hostname) every year, but we also have a public-facing demo server (to act as a public demo site for our academic's specific Moodle-based project). Our academic would prefer that the hostname of the demo server does not change, although we have explained that this would be very difficult to try to implement in practice (at least not without an extended period of downtime to transfer the hostname/DNS from the old server to the new server).

Our normal method of trying to handle such a situation for non-Moodle websites is to initially install the new site under a temporary hostname, and then update the Apache config and DNS to serve the new site with the transferred hostname.

We are not dedicated Moodle admins, so don't have much in-depth knowledge about it, but our academic understands that, unlike many web CMSes which will happily restart successfully under a changed hostname, unfortunately, Moodle does not like it if the server hostname changes from that which Moodle was actually originally installed under?

The only relevant looking information that I have managed to find so far is:

both of which seem to suggest that unfortunately Moodle stores the original hostname in various places in the database, and the database needs to be updated via the Search and Replace tool, which sounds like a potentially rather risky experience?

Another possibility that came to mind was whether it would be possible to set up Apache to proxy requests from the ("behind the scenes") Moodle server to a consistent public-facing hostname, so that it would be invisble to the public that the actual Moodle server hostname had changed. Does anyone know whether Moodle can function successfully in this way?

Any relevant advice would be welcome, although, to be honest, it does sound like setting up the new server with a new hostname would just be the simplest way of doing things.
Average of ratings: -
In reply to David M

Re: Changing Moodle server hostname?

by Ken Task -
Picture of Particularly helpful Moodlers

Not sure am following, but ... if one desires to keep demo.somenet.net that has IP of xx.xx.xxx.xx and spin up a new server using same FQDN, one could do the 'host file trick' - 'stealth apache' ... for lack of a better term.

New server spun up with new IP.   Apache configured to use the FQDN of the original demo.somenet.net in a virtual apache config ... including CA certs.

** in the workstations being used to develop the newly spun up server, host file has been mapped to point to the new IP address.

N.E.W.IP demo.somenet.net demo

When those workstations have that entry in host file, OS will check host file first before DNS.  Workstation sees the server at N.E.W.IP and still interacts with it via demo.somenet.net.

When it's time to go live with NEW, change DNS to point to new IP ... DNS propagation takes less and less these days.  No need to restart the new server.  Just remove the addition made to host file in those workstations.

'spirit of sharing', Ken



In reply to David M

Re: Changing Moodle server hostname?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

Your setup is not easy to understand. This is what I understood:
a) There is a Moodle instance http://demo.example.com which is hosted at a public IP address

b) There is a bunch of Moodle instances like http://moodle-2010.example.com, ... http://moodle-2018.example.com. All resolve to the same private IP address.

c) Then there is the live Moodle, http://moodle.example.com, which also resolves to a private IP address.

That can be done - even if all those Moodles are on the same machine. Differentiate their web directories through Apache Virtual Hosts https://wiki.ubuntuusers.de/Apache/Virtual_Hosts/ and have separate databases and moodledata directories for each.