Change the URL of a Chamilo portal copy

There is a surprising number of cases where you’d want to change the URL of a Chamilo portal, but the more common we see is when you take a backup copy of a portal and want to use that copy to build a new test portal. Obviously, if you keep the same URL, you’re going to have difficulties having them both running at the same time.

Chamilo is not good at managing several URLs (although another article on this blog will help you do that), and even less good at managing a dynamic URL, so there are 3 necessary steps to change the URL (this is valid at least until version 1.11 of Chamilo).

Step 1: Update configuration.php

Whether main/inc/conf/configuration for version 1.9 and below, or app/config/configuration.php for version 1.10 and above, you’ll have to edit the file, locate the $_configuration[‘root_web’] = ‘…’; line and update the value to the new URL.

Once you’ve done that, Chamilo will understand it has to answer to another name. If you’re on the same server in another folder, think about changing $_configuration[‘root_sys’] as well.

Step 2: Update HTML files in the courses/ directory

This is not the only place where some hardcoded links might be present in HTML files, but fixing this directory will certainly fix more than 50% of the issues. The directory is /courses/ in 1.9 and below, and /app/courses/ in 1.10 and above.

Go into the directory and then launch:

find . -type f -exec sed -i ‘s/campus.url1.com/campus.url2.com/g’ {} \;

Where campus.url1.com is the previous URL, and campus.url2.com is the new URL.

This will effectively replace (if you have the permissions to edit the files) all HTML files that might have contained a hardcoded link to the previous URL.

Step 3: Update Apache config

Whether you use Apache or Nginx or any other webserver, you’ll have to update the virtual host config you have (actually, the copy you made of the original portal’s virtual host), to replace URL1 by URL2. Just edit the virtual host config file (usually somewhere like /etc/apache2/sites-available/ or /etc/httpd/ or /etc/nginx/sites-available/) and don’t forget to reload the config afterwards.

This should get your duplicated Chamilo portal up and running!

It's only fair to share...Share on Facebook
Facebook
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Share on Tumblr
Tumblr
Email this to someone
email

2 Comments

  1. Hi, I tried following the steps but still not working for me. I installed original Chamilo via Softaculous. It gave me option to clone it to another subdomain rather but I can’t seem to access the new site? I get the following error

    “domain’s” server IP address could not be found.

    Try running Windows Network Diagnostics.
    DNS_PROBE_FINISHED_NXDOMAIN

    What am I missing or doing wrong? Any advise would gladly be appreciated!

    • Hi Pieter, the error you see seems to be pointing (as the message says) to a misconfiguration at the DNS level *in combination* with Chamilo’s configuration. First make sure the root_web *and* root_sys settings in app/config/configuration.php are correct.
      If these are not enough to get you going, the procedure becomes more complicated and I would suggest you install a new portal rather than trying to fix a clone that doesn’t work (it will be less time-intensive).

Leave a Reply

Your email address will not be published. Required fields are marked *