Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-83424

Restructure moodle code directories

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 5.0
    • General
    • MOODLE_500_STABLE
    • MDL-83424-main
    • Hide

      These testing instructions will require you to reconfigure your web server.

      Configuration

      How this is done will depend heavily on your web server, and configuration.

      The following are provided as examples of how you may reconfigure your web server. Your requirements may differ.

      Apache with site in a sub-directory

      These instructions assume that you have a Moodle site in a sub-directory, such as http://example.com/moodle.

      If you have additional nesting, this may need modification.

      1. * Make a backup of your current apache configuration file before making changes.
      2. Download and extract the moodle-apache_with_83424.zip file attached to this issue.
      3. Place these files in their current structure into your apache configuration directory, usually found at /etc/apache2/ or similar.
      4. Update them according to your needs (see inline documentation).

      Nginx with site in a sub-directory

      This reconfiguration example assumes that your Moodle is hosted inside a directory like https://example.com/mysite

      If you have additional nesting, this may need modification.

      1. * Make a backup of your current nginx configuration file before making changes.
      2. Download and extract the moodle-nginx_with_83424.zip file attached to this issue.
      3. Place these files in their current structure into your nginx configuration directory, usually found at /etc/nginx/ or similar.
      4. Update them according to your needs, for example:
        1. SSL - moodle_servers.conf contains two server stanzas, one for HTTP and one for HTTPS.
          1. If you have SSL certifiates, set the paths for them
          2. If you do not, comment out the second server for port 443
        2. Update the site configuration: blocks/moodle_block.conf:
          1. If the root of your Moodle site's is located at /var/www/moodle, you would set the $root variable to /var/www/moodle/public.
          2. Set the server_names appropriate to your machine
          3. Set the path for your error log.
      5. Restart your web server

      Other notes

      1. If you use MDK please ensure that you are using the latest version, as older versions may not support the new public directory.

      Tests

      Test CLI installation

      1. Create a new Moodle Site and install it via the CLI:

        php public/admin/cli/install.php
        

        1. Confirm that you have a public directory in the root of your Moodle installation
      2. Attempt to log in to your Moodle site via the web interface
        1. confirm that you can access the site

      Test web installation

      1. Create a new Moodle Site and install it via the web interface:
      2. Navigate to your Moodle site in a web browser, such as `http://example.com/yourmoodle`.
      3. Follow the installation instructions
      4. Attempt to log in to your Moodle site via the web interface
        1. confirm that you can access the site

      Upgrade using CLI

      1. Create a new Moodle site running Moodle version 5.0
      2. Navigate to your Moodle site in a terminal
      3. Check out the latest version of the integration / MDL-83424 branch from git
      4. Run the upgrade script:

        php public/admin/cli/upgrade.php
        

        1. Confirm that you have a public directory in the root of your Moodle installation
      5. Attempt to log in to your Moodle site via the web interface
        1. confirm that you can access the site

      Upgrade using web interface

      1. Create a new Moodle site running Moodle version 5.0
      2. Navigate to your Moodle site in a terminal
      3. Check out the latest version of the integration / MDL-83424 branch from git
      4. Visit your Moodle site in a web browser, such as `http://example.com/yourmoodle`.
      5. Follow the upgrade instructions
      6. Attempt to log in to your Moodle site via the web interface
        1. confirm that you can access the site
      Show
      These testing instructions will require you to reconfigure your web server. Configuration How this is done will depend heavily on your web server, and configuration. The following are provided as examples of how you may reconfigure your web server. Your requirements may differ. Apache with site in a sub-directory These instructions assume that you have a Moodle site in a sub-directory, such as http://example.com/moodle . If you have additional nesting, this may need modification. * Make a backup of your current apache configuration file before making changes. Download and extract the moodle-apache_with_83424.zip file attached to this issue. Place these files in their current structure into your apache configuration directory, usually found at /etc/apache2/ or similar. Update them according to your needs (see inline documentation). Nginx with site in a sub-directory This reconfiguration example assumes that your Moodle is hosted inside a directory like https://example.com/mysite If you have additional nesting, this may need modification. * Make a backup of your current nginx configuration file before making changes. Download and extract the moodle-nginx_with_83424.zip file attached to this issue. Place these files in their current structure into your nginx configuration directory, usually found at /etc/nginx/ or similar. Update them according to your needs, for example: SSL - moodle_servers.conf contains two server stanzas, one for HTTP and one for HTTPS. If you have SSL certifiates, set the paths for them If you do not, comment out the second server for port 443 Update the site configuration: blocks/moodle_block.conf : If the root of your Moodle site's is located at /var/www/moodle , you would set the $root variable to /var/www/moodle/public . Set the server_names appropriate to your machine Set the path for your error log. Restart your web server Other notes If you use MDK please ensure that you are using the latest version, as older versions may not support the new public directory. Tests Test CLI installation Create a new Moodle Site and install it via the CLI: php public/admin/cli/install.php Confirm that you have a public directory in the root of your Moodle installation Attempt to log in to your Moodle site via the web interface confirm that you can access the site Test web installation Create a new Moodle Site and install it via the web interface: Navigate to your Moodle site in a web browser, such as ` http://example.com/yourmoodle `. Follow the installation instructions Attempt to log in to your Moodle site via the web interface confirm that you can access the site Upgrade using CLI Create a new Moodle site running Moodle version 5.0 Navigate to your Moodle site in a terminal Check out the latest version of the integration / MDL-83424 branch from git Run the upgrade script: php public/admin/cli/upgrade.php Confirm that you have a public directory in the root of your Moodle installation Attempt to log in to your Moodle site via the web interface confirm that you can access the site Upgrade using web interface Create a new Moodle site running Moodle version 5.0 Navigate to your Moodle site in a terminal Check out the latest version of the integration / MDL-83424 branch from git Visit your Moodle site in a web browser, such as ` http://example.com/yourmoodle `. Follow the upgrade instructions Attempt to log in to your Moodle site via the web interface confirm that you can access the site
    • Hide

      Fails against automated checks.

      Checked MDL-83424 using repository: https://github.com/andrewnicols/moodle.git

      • main [branch: MDL-83424-main | CI Job]
        • Error: The MDL-83424-main branch at https://github.com/andrewnicols/moodle.git does not apply clean to origin/main
        • Error: Merge conflict(s) in file(s):
        • Error: public/completion/tests/behat/multiple_grading_items_activity_completion.feature
        • Error: public/course/format/topics/tests/behat/default_sections.feature
        • Error: public/course/format/weeks/UPGRADING.md
        • Error: public/course/format/weeks/tests/behat/default_sections.feature
        • Error: public/course/tests/behat/max_number_sections.feature
        • Error: public/lib/amd/build/page_title.min.js
        • Error: public/lib/amd/build/page_title.min.js.map
        • Error: public/lib/amd/src/page_title.js
        • Error: public/lib/classes/oauth2/client/microsoft.php
        • Error: public/mod/glossary/tests/behat/overview_report.feature
        • Error: public/mod/subsection/tests/behat/subsection_limit.feature
        • Error: public/version.php

      Should these errors be fixed?

      Built on: Mon Jun 9 04:05:45 UTC 2025

      Show
      Fails against automated checks. Checked MDL-83424 using repository: https://github.com/andrewnicols/moodle.git main [branch: MDL-83424-main | CI Job ] Error: The MDL-83424 -main branch at https://github.com/andrewnicols/moodle.git does not apply clean to origin/main Error: Merge conflict(s) in file(s): Error: public/completion/tests/behat/multiple_grading_items_activity_completion.feature Error: public/course/format/topics/tests/behat/default_sections.feature Error: public/course/format/weeks/UPGRADING.md Error: public/course/format/weeks/tests/behat/default_sections.feature Error: public/course/tests/behat/max_number_sections.feature Error: public/lib/amd/build/page_title.min.js Error: public/lib/amd/build/page_title.min.js.map Error: public/lib/amd/src/page_title.js Error: public/lib/classes/oauth2/client/microsoft.php Error: public/mod/glossary/tests/behat/overview_report.feature Error: public/mod/subsection/tests/behat/subsection_limit.feature Error: public/version.php Should these errors be fixed? Built on: Mon Jun 9 04:05:45 UTC 2025
    • Show
      Launching automatic jobs for branch MDL-83424 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19338/ PHPUnit (sqlsrv / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66063/ Behat (NonJS - boost and classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66064/ Behat (Firefox - boost / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66065/ Behat (Firefox - classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/66066/ App tests (stable app version) / complete) https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19334/ PHPUnit (pgsql / complete) https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19335/ PHPUnit (mariadb / complete) https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/19336/ PHPUnit (sqlsrv / complete) Built on: Wed May 14 03:35:49 UTC 2025

      As discussed in IDEA-75, the idea here is to restructure the Moodle code directories to move public content into a sub-directory of the root.

      In the future this will give us more options including:

      • moving third-party library installation to a deploy phase
      • moving NodeJS build phases to a deploy phase (currently shipped with content)
      • options to move code out of the public directories leaving just deliberately public content
      • options to migrate to a frontend framework in the future

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Votes:
            4 Vote for this issue
            Watchers:
            28 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 weeks, 1 day, 5 hours, 21 minutes
                5w 1d 5h 21m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.