Moodle cloning

Moodle cloning

by Vijay N -
Number of replies: 10

Hi All,

As part of a project I am trying to clone a working moodle site, I noticed the following lines in the config.php file and noticed that there was no direct url for the moodle site listed in the config.php file. The below are the relevant paths to the server,

$CFG->wwwroot = 'https://'.$_SERVER['HTTP_HOST'];

$CFG->dirroot = '/var/www/html/xxx.com/httpdocs';

$CFG->dataroot = '/var/www/html/xxx.com/moodledata';

$CFG->admin = 'admin';

 

Could some one tell me if the above first line  does the same as having a url path to your site: $CFG->wwwroot = 'https://'.$_SERVER['HTTP_HOST'];

 

 

Thanks

V

Average of ratings: -
In reply to Vijay N

Re: Moodle cloning

by Bret Miller -
Picture of Particularly helpful Moodlers

In a way yes. It basically takes whatever the server says the URL is and tells moodle to use it. That can have side effects if your site can be accessed at multiple URL's, but eliminates the need to hard-code it into the config.php.

In reply to Vijay N

Re: Moodle cloning

by Edmund Edgar -

Yes, in principle it has the same effect as if you hard-coded your website URL there.

Two caveats:

1) It allows your site to work with multiple URLs. This is probably mostly OK, but it's possible that strange things will happen if you use it like that. For example, suppose a module decides to save a link to a file with its full absolute URL, as it appears to be when the file is uploaded. If you then show up using the other URL and follow that link, you may hit the login wall of the site with the original URL and be made to log in again before you can see the file.

2) It relies on your Moodle being accessed via the web server. If you try to use a command-line tool like the CLI version of the cron, $_SERVER['HTTP_HOST'] won't be set and any code that runs won't know what your site URL is. (I'm not sure whether it will do a sanity check at that point and give up or just carry on merrily assuming that your site is at "https://", which may or may not be a problem depending what information the tasks your cron runs happen to need.)

You could probably happily use Moodle set up like that without running into either of those problems, but if you know what your site URL is and it isn't going to change for a while, you're probably better off hard-coding it, which is the conventional way to do it.

Average of ratings: Useful (2)
In reply to Edmund Edgar

Re: Moodle cloning

by Vijay N -

Thanks Guys,

 

I am still working on setting this up, some of problems that came up earlier was when setting up a Sub domain for the service (there are 2 moodle sites on the same server with 2 urls each with different ip addresses). The TTL setting were set to 24 hours but we manually changed to 5 minutes to get the new url set up on the new server, apparently it takes 24 hours for everything to run.

 

I will update this post, once I get my hosting company to sort out the subdomain which we need for this cloned moodle site running on a differrent server with different ip address.

In reply to Vijay N

Re: Moodle cloning

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That wwwroot line is wrong - or at least very risky. It should just be a string on the right hand side, e.g.,

$CFG->wwwroot = 'http://my.site.com/moodle'

I've seen this before, and while I'm not sure where it came from, I assume it was created on one of these "one click installers".

If you want to clone a site, copy the database, the moodledate files and the actual moodle files and reflect the changes in each moodle's config.php. That's just about it.
In reply to Howard Miller

Re: Moodle cloning

by Vijay N -

We use Rackspace to provide hosting of our service, so its not as simple as changing the config file, Rackspace needs to do the setup of the DNS names and a few other things.

In reply to Vijay N

Re: Moodle cloning

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is nothing to do with DNS, it's the config.php file in the root of your Moodle install. You *must* have control over that and you *must* know what the URL of your Moodle site is, surely?

If your site is... http://www.vijay.com/moodle... then that's what goes in $CFG->wwwwoot. Simple as that.
In reply to Howard Miller

Re: Moodle cloning

by Vijay N -

The latest issue is as follows:

1) I got the cloned site up and running (its still using the server line and not the url line)

2) I got the ssl certificate up and running: -wild card

3) I was able to login to the site

 

Now comes the pending issue: Server time out issue. I keep getting the session time out issue when navigating between pages. I am not sure if this is a permission issue on the folders. 

The specific error is : A server error that affects your login session was detected. Please login again or restart your browser

This is a linux server and the following has been set on the moodledata folder: rwxr-sr-x

while moodle folder has: rwxrwsr-x

I am almost certain that there is a permission issue that is causing the session time out happening without even warning me about the timeout.

 

any ideas?

Vijay

In reply to Howard Miller

Re: Moodle cloning

by R.T. Brown -

The use of an envirnment variable for wwwroot is appealing to me because of dynamically created instances with in a cloud environment.

CFG->wwwroot = 'http://' . $_SERVER['HTTP_HOST'] . '';

Host names change as you add and substract servers. Is this not a valid use case / reason to use this convention?