Site 'reading' wrong html file

Site 'reading' wrong html file

Quintin Seegers -
回帖数:6
Particularly helpful Moodlers的头像
Server: Linux Ubuntu
Moodle: v4.3

I have moved my moodle installation to different folders on the server (we'll be hosting multiple moodle instances on the same server). I have my moodle and moodledata folders in the following respective locations on my server:
  • /var/www/training.kilimanjaro-consulting.com/moodledata
  • /var/www/training.kilimanjaro-consulting.com/public_html/moodle
When setting up the virtual servers in Apache, I created an index.html in /var/www/training.kilimanjaro-consulting.com/public_html. This was to test that the virtual host was working correctly. To prevent users from logging in while I'm doing some data maintenance, I've created a climaintenance.html file in the moodledata folder, with some basic html for users to see.
 
In my Virtual Server setup, I have the DocumentRoot as /var/www/training.kilimanjaro-consulting.com/public_html/moodle. In my /moodle/config.php, I have the dataroot as /var/www/training.kilimanjaro-consulting.com/moodledata. However, the server is not reading the /moodledata/climaintenance.html file, but the /public_html/index.html file instead. If I rename the index.html file, I get a server directory view. It appears the server is loading /public_html instead of /public_html/moodle.
 
Any suggestions on what I might be missing?
回复Quintin Seegers

Re: Site 'reading' wrong html file

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
> However, the server is not reading the /moodledata/climaintenance.html file, but the /public_html/index.html file instead.

That is the expected behaviour. Imagine, if the whole world is able to fish your files by just finding out the correct URL! That is also why the advice in the installation instructions to put moodledata outside of the DocumentRoot of the web server. The obvious question, how does Moodle find them? Moodle code has some magic. ;)

> If I rename the index.html file, I get a server directory view.

Then your web server is set to show directory indexes. See https://httpd.apache.org/docs/2.4/mod/core.html#directory which is considered weak securitywise. Moodle security report will show a red flag.

> It appears the server is loading /public_html instead of /public_html/moodle.

Contracts what you said earlier:
> In my Virtual Server setup, I have the DocumentRoot as /var/www/training.kilimanjaro-consulting.com/public_html/moodle.
回复Visvanath Ratnaweera

Re: Site 'reading' wrong html file

Quintin Seegers -
Particularly helpful Moodlers的头像
> That is the expected behaviour.

How is that expected behaviour? I originally had it set up as follows:
moodledata: /var/moodledata
moodle: /var/www/html/moodle
DocumentRoot in server config file: /var/www/html/moodle
dataroot in moodle config.php: /var/moodledata

That worked perfectly as expected. The only difference now is additional folder levels.

Referring to Example one in https://docs.moodle.org/311/en/Step-by-step_Installation_Guide_for_Ubuntu, how I've set up my structure folder isn't unusual or weak security when running multiple instances of Moodle.

I did not have these issues when testing these on a mirror instance of my site, so I'm baffled why it's an issue.
回复Quintin Seegers

Re: Site 'reading' wrong html file

Howard Miller -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
I'm a bit lost... firstly, your 'moodledata' directory should NOT be accessible to the web. That makes it insecure.

Secondly, how is Apache going to access moodledata if the document root is public_html?
回复Quintin Seegers

Re: Site 'reading' wrong html file

Ken Task -
Particularly helpful Moodlers的头像

"we'll be hosting multiple moodle instances on the same server"

In directories using same FQDN or Virtual Apaches using different FQDN + directories?

Is this a Web Hosting Management/cPanel setup or just a cPanel setup or a no panel setup?

What do you get if you issue:

apache2ctl -S

from command line?

Not sure why there would be a public_html directory ... in many WHM/cPanel/Plesk remotely hosted setups, that is in a 'user jail' ... like /home/[accountlogin]/public_html/

Apache user already has a home directory in /var/www/

Document roots for virtual apaches could go in /var/www/whatever

a unique moodledata directory per virtual apache could be in /var/www/ - those directories are not directly accessible unless there is something in config of a virtual domain or main apache config to allow that. 

'SoS', Ken

回复Quintin Seegers

Re: Site 'reading' wrong html file

Emma Richardson -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像
Moodle uses an index.php file which is creating the html file. You are just trying to bypass that...for a temporary file, try moving your climaintenance file to the public_html/index file and that should take care of that.

The others are right - you do not want your moodledata folder exposed. However, it seems that your moodle site is not loading? That apache or webserver is pulling from public_html instead of moodle? Check the following: 1. double check the spelling of your paths and make sure you have slashes in the same place on the new references etc... 2. check that you have the correct ownership and permissions on your moodle and moodledata folders..
回复Emma Richardson

Re: Site 'reading' wrong html file -RESOLVED-

Quintin Seegers -
Particularly helpful Moodlers的头像
Thanks @Ken and @Emma - your replies put me right. Turns out the instructions I followed for setting up multiple virtual servers wasn't quite appropriate for a moodle install. I have moved my moodle folders accordingly:
  • /var/clientmoodledata
  • /var/internalmoodledata
  • /var/www/html/clientmoodle
  • /var/www/html/internalmoodle
Following this, I also updated the DocumentRoot in the config file for my two virtual servers:
  • /var/www/html/clientmoodle
  • /var/www/html/internalmoodle
and updated the respective moodle config.php's:
  • /var/clientmoodledata
  • /var/internalmoodledata
After restarting Apache and running apache2 -S (as Ken suggested), both sites are now loading correctly.
 
Thanks, Quintin