We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54497
    • 15 Posts
    Hello Folks,

    I'm a seasoned IT / Sysadmin with years of experience. Lots of tasks done over the years in Windows and Linux systems. Including a wide variety of PHP skills.

    I setup a new MODX 2.6.5 the other day -- NO ISSUES. Manager section and front end worked fine.
    I then found the security note about moving CORE from outside the web root.

    Moved CORE up level higher and change the paths in the config files.
    Wouldn't work...

    I deleted the DB and all files.
    I did the CORE move first before my second install. No ERRORS during the install, but nothing works.

    I will say that I have heard a lot of good things about MODX.
    I wish the setup/directions were better written. The directions jump around a lot and don't follow a logic flow. Also the section that says what directories need to be writable... by PHP... What does that mean?

    Now back to my moving CORE issue.
    my document root is /var/www/sites/blah.com/html
    my core is /var/www/sites/blah.com/core

    I have changed the CORE path in the config files to: ../core/ and /var/www/sites/blah.com/core/
    Both dont work...

    if you look at the apache logs:
    include_once(/var/www/sites/blah.com/html../core/model/modx/modx.class.php

    It is appending it to the document root path...
    please advise.

    This question has been answered by BobRay. See the first response.

      • 17301
      • 932 Posts
      There should a forward slash after the core so it reads:

      if (!defined('MODX_CORE_PATH')) {
          $modx_core_path= '/var/www/sites/blah.com/core/';
          define('MODX_CORE_PATH', $modx_core_path);
      }


      Also I believe the core security issue you first get when installing and logging in can be resolved just by renaming the htaccess file in that folder. Though moving this outside of the public folder is also a great idea smiley
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 54497
        • 15 Posts
        That is defined as you advise.
        That is in file /var/www/sites/blah.com/core/config/config.inc.php

        When requesting blah.com/manager
        [Thu Aug 16 16:31:21 2018] [error] [client 107.77.76.116] PHP Warning: include_once(/var/www/sites/blah.com/html/core/model/modx/modx.class.php): failed to open stream: No such file or directory in /var/www/sites/blah.com/html/manager/index.php on line 37

        cat /var/www/sites/blah.com/html/manager/config.core.php

        <?php
        /*
        * This file is managed by the installation process. Any modifications to it may get overwritten.
        * Add customizations to the $config_options array in `core/config/config.inc.php`.
        *
        */
        define('MODX_CORE_PATH', dirname(__DIR__) . '/core/');
        define('MODX_CONFIG_KEY', 'config');

        What should this path be defined as in manager/config.core.php ?
          • 3749
          • 24,544 Posts
          There are three config.core.php files in these directories. All of them need to point to the location of your core directory, and if you move/rename the core, you need to manually edit all three of them to correct the core path. Usually, the most reliable setting for the core path in those files is the full, absolute path to the core directory.

          modx root
          connectors
          manager
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 54497
            • 15 Posts
            cat /var/www/sites/blah.com/html/config.core.php file:
            <?php
            /*
            * This file is managed by the installation process. Any modifications to it may get overwritten.
            * Add customizations to the $config_options array in `core/config/config.inc.php`.
            *
            */
            define('MODX_CORE_PATH', dirname(__FILE__) . '/var/www/sites/blah.com/core/');
            define('MODX_CONFIG_KEY', 'config');


            cat /var/www/sites/blah.com/html/connectors/config.core.php file:
            <?php
            /*
            * This file is managed by the installation process. Any modifications to it may get overwritten.
            * Add customizations to the $config_options array in `core/config/config.inc.php`.
            *
            */
            define('MODX_CORE_PATH', dirname(__DIR__) . '/var/www/sites/blah.com/core/');
            define('MODX_CONFIG_KEY', 'config');


            cat /var/www/sites/blah.com/html/manager/config.core.php file:
            <?php
            /*
            * This file is managed by the installation process. Any modifications to it may get overwritten.
            * Add customizations to the $config_options array in `core/config/config.inc.php`.
            *
            */
            define('MODX_CORE_PATH', dirname(__DIR__) . '/var/www/sites/blah.com/core/');
            define('MODX_CONFIG_KEY', 'config');





            Does this look correct ?
              • 3749
              • 24,544 Posts
              I'm afraid not. The whole point of moving the core is to get it *above* the web root. Putting it below the
              MODX root directory doesn't make it much more secure.

              Also, as I said: Usually, the most reliable setting for MODX_CORE_PATH in those files is the full, absolute path to the core directory. That means not using __FILE__ and __DIR__.

              The config.core.php files are often "included" in other files, which means those constants will set to the directory of the including file and its parent -- hence the need for a full absolute path.

              Did you run Setup after first installing the files and then make sure the site worked before moving the core?




                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 54497
                • 15 Posts
                CORE is above the web root.

                web root = /var/www/sites/blah.com/html
                core = /var/www/sites/blah.com/core

                So I remove the That means not using __FILE__ and __DIR__. sections ?
                I have no problem modify the paths, but I don't want to rewrite an working system.

                Did you run Setup after first installing the files and then make sure the site worked before moving the core? NO -- because.... I followed https://docs.modx.com/revolution/2.x/getting-started/installation/advanced-installation

                I moved the CORE folder before in install and it promoted me for the path to core.
                  • 46886
                  • 1,154 Posts
                  We'll get you straight, where are you now?

                  Here is a sample of my core config.php file

                  if (!defined('MODX_CONNECTORS_PATH')) {
                      $modx_connectors_path= '/home/webaccount/public_html/connectors/';
                      $modx_connectors_url= '/connectors/';
                      define('MODX_CONNECTORS_PATH', $modx_connectors_path);
                      define('MODX_CONNECTORS_URL', $modx_connectors_url);
                  }
                    • 54497
                    • 15 Posts
                    Testing this morning blah.com/manager page...
                    Apache error log:
                    [Fri Aug 17 07:38:35 2018] [error] [client 107.77.76.117] PHP Warning: include_once(/var/www/sites/blah.com/html/var/www/sites/blah.com/core/model/modx/modx.class.php): failed to open stream: No such file or directory in /var/www/sites/blah.com/html/manager/index.php on line 37


                    There is something basic I'm missing here.
                    All its doing is COMBINING the two paths to find core... Core is just up one level.

                    setting core to '../core/' makes a lot of sense, but when I do that the error is:
                    include_once(/var/www/sites/blah.com/html/../core/model/modx/modx.class.php):
                      • 54497
                      • 15 Posts
                      Quote from: nuan88 at Aug 17, 2018, 11:41 AM
                      We'll get you straight, where are you now?

                      Here is a sample of my core config.php file

                      if (!defined('MODX_CONNECTORS_PATH')) {
                          $modx_connectors_path= '/home/webaccount/public_html/connectors/';
                          $modx_connectors_url= '/connectors/';
                          define('MODX_CONNECTORS_PATH', $modx_connectors_path);
                          define('MODX_CONNECTORS_URL', $modx_connectors_url);
                      }
                      What is the path to this file?