Moodle - Change a moodle site's domain name

To change your moodle site's domain name, for example from "" to "" you have to do following things:

0. Point to your moodle site's IP address

1. Go to the replace admin tool in your moodle (still running at the and replace with in every record that has the url:
( version >= 2.5)

2. Open /moodle/root/path/config.php and change the wwwroot to the new domain:

$CFG->wwwroot   = '';

3. Change your nginx / apache configuration to retrieve server name as the (I use nginx ):



4. Restart nginx and php5-fpm:

$ sudo service nginx restart
$ sudo service php5-fpm restart

5. In addition, you can also clean the cache of your moodle:

$ sudo rm -rf /moodle/data/path/cache/cachestore_file/default_application/core_databasemeta/*
$ sudo rm -rf /moodle/data/path/cache/cachestore_file/default_application/core_config/*

Now you can access your moodle site with the new domain name.