Server Name and DocRoot & WWWRoot Redirect

Server Name and DocRoot & WWWRoot Redirect

by Simon Harbinson -
Number of replies: 4

Config: Ubuntu Server LTS 14.04, Moodle 3.0.2+ (Build: 20160211)

Hi I have finished building my first Moodle on Linux and have a some questions:

1: The server (Computer name) is called "Subuntu", the file /etc/apache2/apache2.conf, States the ServerName as "localhost" to slightly complicate the issue the DNS server has the server name as lmserver and finally we have an internal DNS zone that matches the external host name so that we can use the same address internally as externally.

Not knowing Linux that well if I change the Computer name to lmserver from subuntu will Apache, PHP, MySQL or Moodle care, also is it required that the server name stated in the apache2.conf has to match the DNS name "lmserver" or the server name "Subuntu" because if not I'll just leave it.

Current Host files

hostname:
subuntu

host:
127.0.0.1 localhost
127.0.1.1 Subuntu

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
<Internal IP> LMServer

2: Although I thought I enabled HTTPS correctly it would seem that the site root is still http.

3: I'm Having an issue with the Document root, I have managed to get the Incorrect access page to go direct to the WWWRoot without a delay thanks to Howard Miller's post (here) but when I change the Document Root from  "/var/www/html" to "/var/www/html/moodle" and alter the WWWRoot to reflect the change, the system starts to loose all its theme colouring and some links as they are still using the old WWWRoot path.

Am I missing a process I need to do (I have rebooted and restarted the services).

Thanks Simon

Average of ratings: -
In reply to Simon Harbinson

Re: Server Name and DocRoot & WWWRoot Redirect

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

The computer name should not matter as long as the DNS is working.  I suggest leaving it alone.  Apache pointing to localhost just means that it is pointing to the machine it is on - that is fine.

For your missing images, etc, try clearing the caches.   This might also fix the https issue - not sure on that one.  You might also need to run the replace.php utility changing the old server name http://yourmoodle.com to https://yourmoodle.com.

Average of ratings: Useful (1)
In reply to Simon Harbinson

Re: Server Name and DocRoot & WWWRoot Redirect

by Ken Task -
Picture of Particularly helpful Moodlers

Moodle uses wwwroot variable ... ie, the URL to your site ... in every link to files/themes/css, etc.. in the links recorded and stored in your DB.   Previously, before making 'moodle' directory document root, site had recorded

http://yoursite/moodle/

in all of those links.

Fix: easy (first backup database):

http://site/admin/tool/replace/ via URL line.

In the search box the old URL: http://site/moodle/ - be sure to include the http:// in front and the trailing slash at the end.

replace with: http://site/

Be sure here again to include http:// in front and the trailing slash.

Now all the DB references pointed to your site will be changed to the corrected wwwroot you've edited in config.php.  Purge the server caches.  Might also check your favorite/bookmarks and change them.   Clear your browser cookies and cache as well.   If you have users in the system already and using, post something on your front page informing them they need to update their bookmarks/favorites, etc..    And, IF  anyone using the Moodle app, they too might need to make the change in the config of their app.

As far as https ... the first step is to make sure your server responds to https (which really uses port 443).  Ubuntu has docs on how to do that.   But do take the time to do that.   The certificate at this stage is a self-signed certificate and not trusted.  This to warn that browsers will complain.   That's OK ... they should ... that means things *are* working.

At the same time, one has to begin the process of acquiring a valid certificate from a Certificate of Authority (CA).   All are commercial ... ie, you purchase a certificate from a CA.   All CA's have how-2's so suggest shopping for where one would want to purchase and then reading their docs/FAQ's for the process they use.   That will include creating a 'certificate request' (CSR) on your server that you have to submit to the CA of choice.

Example: http://www.entrust.net/knowledge-base/technote.cfm?tn=8231

For setting up server to run https:

https://help.ubuntu.com/lts/serverguide/httpd.html

After you get your server on https:// you will have to do the search/replace again only this time search for:

http://yoursite/ replace with https://yoursite/

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Simon Harbinson

Re: Server Name and DocRoot & WWWRoot Redirect

by Simon Harbinson -

Hi Emma and Kan Thanks for your responses.

I did clear the cache on my workstation but the issue was that at that point only three of user were using the system and links for me and one other were accepting the variable WWWRoot but links for the other user in a post where still reporting back the old WWWRoot path.  I'm not sure I have messed anything up as when I moved to HTTPS the formatting for the theme disappeared once I have logged in and out after a few mins this seem to fix its self.

Time to get reading again thanks.

Sorry one more question, in the setup I was following it states to chmod the moodle folder for security using 

$sudo chmod -R 0755 /var/www/html/moodle

and close it with 

$sudo chmod -R 777 /var/www/html/moodle


is this still required if I'm going HTTPS ?


Simon


In reply to Simon Harbinson

Re: Server Name and DocRoot & WWWRoot Redirect

by Ken Task -
Picture of Particularly helpful Moodlers

https just encripts the traffic over the wire during transport of data.  It doesn't prevent a hack to your site.   Thus, yes, ownerships and permissions are still considered 'required'.

BTW, don't ever assume that using https means everything is OK now.   As of the last year or so, there has been issues with openssl and thus also https that affect sites running https.    Take the approach that, as a human, for now, you've done what you can humanly do to secure the site (although checking security from time to time is a good idea).

Nothing is 'Ft. Knox' ... where the gold supposedly resides in US.   Even 'Ft. Knox' itself isn't 'Ft. Knox'!!!!

'spirit of sharing', Ken

Average of ratings: Useful (1)