moodle on localhost - Install in subdirectory

moodle on localhost - Install in subdirectory

by Frank Walter -
Number of replies: 9

Hallo

I installed moodle 3.11.5 (for testing purpose) on my Windows 10 computer where I have Apache 2.4 installed (no WAMP or such) and PHP 8.0.
I have many test sites in my apache running.
I open moodle3 with:

http://localhost/moodle3

Now I have a moodle plugin which has a kind of overview button, the button opens the blocks directory in moodle, but without the directory moodle3 in the link, the (wrong) link is:

http://localhost/blocks/myplugin/overview.php

When I change the link (in the address bar of my browser), adding "moodle3/" to:

http://localhost/moodle3/blocks/myplugin/overview.php

I can open that overview.
But the button's link in the plugin is broken (404, which is clear, as moodle is running under localhost/moodle3/).

Is there an switch somewhere, where I can tell moodle it is not the only system (under root dir) in my apache webserver?
Seems like I checked the wrong checkbox when I installed it, but I dont find it.

Thanks for hints.
frank

Average of ratings: Useful (1)
In reply to Frank Walter

Re: moodle on localhost - Install in subdirectory

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Moodle doesn't save the directory it is in. But there is a 'wwwroot'. Is this what you have in config.php?
$CFG->wwwroot='http://localhost/moodle3';
If so, I suspect a bug in the plug-in. What is this "overview" plug-in?
In reply to Visvanath Ratnaweera

Re: moodle on localhost - Install in subdirectory

by Frank Walter -
It is a special created plugin from 2020 (not available for public).
The Plugin works in another installation, but I think there it is in the root dir (as moodle is the main web site there).
In the config I have:

$CFG->wwwroot = 'http://localhost/moodle3';
$CFG->dataroot = 'C:\\Apache24\\moodle3data';
// added for test:
$CFG->dirroot = 'C:\\Apache24\\moodle3';

Good possible, that the plugin is not checking wwwroot as it was maybe created for that page in the root dir of the webserver.
Have to check this...
Thank for the hint.
In reply to Frank Walter

Re: moodle on localhost - Install in subdirectory

by Ken Task -
Picture of Particularly helpful Moodlers

You haven't mentioned, but I'll ask ... each instance has it's own moodledata directory and own DB.   Correct?   Thus, each has it's own cache.

With multiple code bases, I set a unique cookie prefix for each instance.   In your case for the 'moodle3', the cookie prefix I'd suggest is 'moodle3_'.   Since you might be in and out of a couple instances comparing why plugins work in one and not another, unique cookie prefix would help browser from getting confused.

'SoS', Ken


In reply to Ken Task

Re: moodle on localhost - Install in subdirectory

by Frank Walter -
OK, I tried to put as sessioncookie prefix "moodle3_" (in Website-Administration > Server > Sitzungsinformation > Cookie-Prefix) but I get an error about it:
Dieser Wert ist ungültig: moodle3_ (means: not valid).
So I put "moodle3" there (the underscore was not allowed).

But it does not change the (wrong) link of my overview.
So I am pretty sure it is the hardcoded programming of this plugin, I should fix it.
Anyway there are some warnings (when debug enabled) with PHP 8.0 (will be worse on 8.1 I guess, maybe errors then...) so I need to work on it anyway.
Thank!
In reply to Frank Walter

Re: moodle on localhost - Install in subdirectory

by Justin walker -
It sounds like the plugin is generating a link that is missing the "moodle3" directory in the URL, causing the link to point to the wrong location on your server.

To fix this issue, you can modify the code in the plugin to include the "moodle3" directory in the URL. Specifically, you'll need to modify the code that generates the link to something like this:
localhost/moodle3/blocks/myplugin/overview.php

By including the "moodle3" directory in the URL, you'll be able to ensure that the link points to the correct location on your server.
In reply to Frank Walter

Re: moodle on localhost - Install in subdirectory

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
You might want to mention how you installed the plugin.
In reply to Rick Jerz

Re: moodle on localhost - Install in subdirectory

by Frank Walter -
Installed it "normally":
Website Administration > Plugins > Plugin installieren

There are two plugins, one report (has to be installed first, if not installation is with errors) and one blocks. Both for moodle 3.8 I guess because the name is blocks_gnppoints_moodle38_2020072800.zip and report_gnppoints_moodle38_2020072800.zip
In reply to Frank Walter

Re: moodle on localhost - Install in subdirectory

by Ken Task -
Picture of Particularly helpful Moodlers

Couple of things that might help ... caches - cleared on server and workstation.

So you your plugins are a set .. one is dependent upon the other for correct install.   Might look at other plugins that have 'dependencies' and see how they are packaged and installed (files in downloads of the zips).  WIRIS is one ... needs the Atto/TinyMCE editor addons installed as well or doesn't work.

'SoS', Ken