We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42465
    • 33 Posts
    Hi all,

    I'm in the processing of moving a site from a development server to a live server and I've run into a problem on the live installation. I'm hoping that it's something simple like a misconfiguration of confgig.inc.php.

    The home page throws a 503 error, the manager throws a blank screen and the test script mentioned in the official "Moving your site..." guide (http://rtfm.modx.com/revolution/2.x/administering-your-site/moving-your-site-to-a-new-server) gives the following error:


    Error

    The following errors were detected:
    modX class not found! The modX class file should be located at ../core/model/modx/modx.class.php

    (I've had a look at the file in question but can't make sense of it.)


    The dev copy (which works just fine) has file paths like this:

    
    ...
    
    if (!defined('MODX_CORE_PATH')) {
        $modx_core_path= '/home/mysite/www/mysite.com/public/core/';
        define('MODX_CORE_PATH', $modx_core_path);
    }
    if (!defined('MODX_PROCESSORS_PATH')) {
        $modx_processors_path= '/home/mysite/www/mysite.com/public/core/model/modx/processors/';
        define('MODX_PROCESSORS_PATH', $modx_processors_path);
    }
    if (!defined('MODX_CONNECTORS_PATH')) {
        $modx_connectors_path= '/home/mysite/www/mysite.com/public/connectors/';
        $modx_connectors_url= '/connectors/';
        define('MODX_CONNECTORS_PATH', $modx_connectors_path);
        define('MODX_CONNECTORS_URL', $modx_connectors_url);
    }
    if (!defined('MODX_MANAGER_PATH')) {
        $modx_manager_path= '/home/mysite/www/mysite.com/public/manager/';
        $modx_manager_url= '/manager/';
        define('MODX_MANAGER_PATH', $modx_manager_path);
        define('MODX_MANAGER_URL', $modx_manager_url);
    }
    
    ...
    


    On the live site I've dispensed with the containing directories (i.e. home/mysite/www/mysite.com/public/) and put everything in the public folder e.g. assets, connectors, core manager and so on directly into the root and amend the file paths as below. Do you see anything obviously wrong with this?

    
    ...
    
    if (!defined('MODX_CORE_PATH')) {
        $modx_core_path= '/core/';
        define('MODX_CORE_PATH', $modx_core_path);
    }
    if (!defined('MODX_PROCESSORS_PATH')) {
        $modx_processors_path= '/core/model/modx/processors/';
        define('MODX_PROCESSORS_PATH', $modx_processors_path);
    }
    if (!defined('MODX_CONNECTORS_PATH')) {
        $modx_connectors_path= '/connectors/';
        $modx_connectors_url= '/connectors/';
        define('MODX_CONNECTORS_PATH', $modx_connectors_path);
        define('MODX_CONNECTORS_URL', $modx_connectors_url);
    }
    if (!defined('MODX_MANAGER_PATH')) {
        $modx_manager_path= '/manager/';
        $modx_manager_url= '/manager/';
        define('MODX_MANAGER_PATH', $modx_manager_path);
        define('MODX_MANAGER_URL', $modx_manager_url);
    }
    if (!defined('MODX_BASE_PATH')) {
        $modx_base_path= '/';
        $modx_base_url= '/';
        define('MODX_BASE_PATH', $modx_base_path);
        define('MODX_BASE_URL', $modx_base_url);
    }
    if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
        $isSecureRequest = false;
    } else {
        $isSecureRequest = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
    }
    if (!defined('MODX_URL_SCHEME')) {
        $url_scheme=  $isSecureRequest ? 'https://' : 'http://';
        define('MODX_URL_SCHEME', $url_scheme);
    }
    if (!defined('MODX_HTTP_HOST')) {
        if(defined('PHP_SAPI') && (PHP_SAPI == "cli" || PHP_SAPI == "embed")) {
            $http_host='mysite.com';
            define('MODX_HTTP_HOST', $http_host);
        } else {
            $http_host= $_SERVER['HTTP_HOST'];
            if ($_SERVER['SERVER_PORT'] != 80) {
                $http_host= str_replace(':' . $_SERVER['SERVER_PORT'], '', $http_host); // remove port from HTTP_HOST
            }
            $http_host .= ($_SERVER['SERVER_PORT'] == 80 || $isSecureRequest) ? '' : ':' . $_SERVER['SERVER_PORT'];
            define('MODX_HTTP_HOST', $http_host);
        }
    }
    if (!defined('MODX_SITE_URL')) {
        $site_url= $url_scheme . $http_host . MODX_BASE_URL;
        define('MODX_SITE_URL', $site_url);
    }
    if (!defined('MODX_ASSETS_PATH')) {
        $modx_assets_path= '/assets/';
        $modx_assets_url= '/assets/';
        define('MODX_ASSETS_PATH', $modx_assets_path);
        define('MODX_ASSETS_URL', $modx_assets_url);
    }
    if (!defined('MODX_LOG_LEVEL_FATAL')) {
        define('MODX_LOG_LEVEL_FATAL', 0);
        define('MODX_LOG_LEVEL_ERROR', 1);
        define('MODX_LOG_LEVEL_WARN', 2);
        define('MODX_LOG_LEVEL_INFO', 3);
        define('MODX_LOG_LEVEL_DEBUG', 4);
    }
    if (!defined('MODX_CACHE_DISABLED')) {
        $modx_cache_disabled= false;
        define('MODX_CACHE_DISABLED', $modx_cache_disabled);
    }
    
    ...
    
    


    Thanks


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

    [ed. note: bob-rooney last edited this post 13 years ago.]
    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Check the three config.core.php files - one in the site root, one in /connectors/ and one in /manager/. They all three need to have the correct path (not URL) to your core directory. For example, on my MAMP installation they all three look like this:
      <?php
      define('MODX_CORE_PATH', '/Applications/MAMP/htdocs/revo229/core/');
      define('MODX_CONFIG_KEY', 'config');
      ?>

      The paths in your config.inc.php file cannot be /core/... anything; that path is starting from the root of your server's file system. Again, on my MAMP installation:
      if (!defined('MODX_CORE_PATH')) {
          $modx_core_path= '/Applications/MAMP/htdocs/revo229/core/';
          define('MODX_CORE_PATH', $modx_core_path);
      }
      if (!defined('MODX_PROCESSORS_PATH')) {
          $modx_processors_path= '/Applications/MAMP/htdocs/revo229/core/model/modx/processors/';
          define('MODX_PROCESSORS_PATH', $modx_processors_path);
      }
      if (!defined('MODX_CONNECTORS_PATH')) {
          $modx_connectors_path= '/Applications/MAMP/htdocs/revo229/connectors/';
          $modx_connectors_url= '/revo229/connectors/';
          define('MODX_CONNECTORS_PATH', $modx_connectors_path);
          define('MODX_CONNECTORS_URL', $modx_connectors_url);
      }
      if (!defined('MODX_MANAGER_PATH')) {
          $modx_manager_path= '/Applications/MAMP/htdocs/revo229/manager/';
          $modx_manager_url= '/revo229/manager/';
          define('MODX_MANAGER_PATH', $modx_manager_path);
          define('MODX_MANAGER_URL', $modx_manager_url);
      }
      if (!defined('MODX_BASE_PATH')) {
          $modx_base_path= '/Applications/MAMP/htdocs/revo229/';
          $modx_base_url= '/revo229/';
          define('MODX_BASE_PATH', $modx_base_path);
          define('MODX_BASE_URL', $modx_base_url);
      
      ...
      
      if (!defined('MODX_ASSETS_PATH')) {
          $modx_assets_path= '/Applications/MAMP/htdocs/revo229/assets/';
          $modx_assets_url= '/revo229/assets/';
          define('MODX_ASSETS_PATH', $modx_assets_path);
          define('MODX_ASSETS_URL', $modx_assets_url);
      }
      
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22840
        • 1,572 Posts
        As Susan has already stated the path URL should be relative from the root of the server, for example:

        if (!defined('MODX_CORE_PATH')) {
            $modx_core_path= '/home/paulple/public_html/core/';
            define('MODX_CORE_PATH', $modx_core_path);
        }
        if (!defined('MODX_PROCESSORS_PATH')) {
            $modx_processors_path= '/home/paulple/public_html/core/model/modx/processors/';
            define('MODX_PROCESSORS_PATH', $modx_processors_path);
        }
        if (!defined('MODX_CONNECTORS_PATH')) {
            $modx_connectors_path= '/home/paulple/public_html/connectors/';
            $modx_connectors_url= '/connectors/';
            define('MODX_CONNECTORS_PATH', $modx_connectors_path);
            define('MODX_CONNECTORS_URL', $modx_connectors_url);
        }
        if (!defined('MODX_MANAGER_PATH')) {
            $modx_manager_path= '/home/paulple/public_html/manager/';
            $modx_manager_url= '/manager/';
            define('MODX_MANAGER_PATH', $modx_manager_path);
            define('MODX_MANAGER_URL', $modx_manager_url);
        }
        if (!defined('MODX_BASE_PATH')) {
            $modx_base_path= '/home/paulple/public_html/';
            $modx_base_url= '/';
            define('MODX_BASE_PATH', $modx_base_path);
            define('MODX_BASE_URL', $modx_base_url);


        Try and see if you can run setup in upgrade mode as that may fix the path issues
          • 42465
          • 33 Posts
          Thanks folks. It was indeed a file path problem.

          I had hoped that a relative path would work (e.g. ../core/) but alas this is not the case. In the end I got the server's absolute file path by popping the below into a file and then opening it - e.g www.mysite/filepath.php

          <?php
          echo getcwd();
          ?>
          
          http://php.net/manual/en/function.getcwd.php
          


          Make sure to delete afterwards.

            • 45237
            • 1 Posts
            armyofda12mnkeys Reply #5, 13 years ago
            I just inherited a modx site this week...
            Why not have everything in a 'relative calculated absolute' path so when moving a site don't have to deal with these issues.
            Example... this works for me ... not sure if any other files need to be modified:


            manager/config.core.php:
            <?php
            ...
            
            $current_dir = dirname(__FILE__);
            //error_log('core/config1/:'.$current_dir);
            $install_dir = $current_dir .DIRECTORY_SEPARATOR. '..' .DIRECTORY_SEPARATOR. '..' .DIRECTORY_SEPARATOR;
            //error_log('core/config2/:'.$install_dir);
            $realpath_install_dir = realpath($install_dir);
            //error_log('core/config3/:'.$realpath_install_dir);
            
            if (!defined('MODX_CORE_PATH')) {
                $modx_core_path= $realpath_install_dir .DIRECTORY_SEPARATOR. 'core' .DIRECTORY_SEPARATOR;
                define('MODX_CORE_PATH', $modx_core_path);
            }
            if (!defined('MODX_PROCESSORS_PATH')) {
                $modx_processors_path= $realpath_install_dir .DIRECTORY_SEPARATOR. 'core' .DIRECTORY_SEPARATOR. 'model' .DIRECTORY_SEPARATOR. 'modx' .DIRECTORY_SEPARATOR. 'processors' .DIRECTORY_SEPARATOR;
                define('MODX_PROCESSORS_PATH', $modx_processors_path);
            }
            if (!defined('MODX_CONNECTORS_PATH')) {
                $modx_connectors_path= $realpath_install_dir .DIRECTORY_SEPARATOR. 'connectors' .DIRECTORY_SEPARATOR;
                $modx_connectors_url= '/connectors/';
                define('MODX_CONNECTORS_PATH', $modx_connectors_path);
                define('MODX_CONNECTORS_URL', $modx_connectors_url);
            }
            if (!defined('MODX_MANAGER_PATH')) {
                $modx_manager_path= $realpath_install_dir .DIRECTORY_SEPARATOR. 'manager' .DIRECTORY_SEPARATOR;
                $modx_manager_url= '/manager/';
                define('MODX_MANAGER_PATH', $modx_manager_path);
                define('MODX_MANAGER_URL', $modx_manager_url);
            }
            if (!defined('MODX_BASE_PATH')) {
                $modx_base_path= $realpath_install_dir .DIRECTORY_SEPARATOR;
                $modx_base_url= '/';
                define('MODX_BASE_PATH', $modx_base_path);
                define('MODX_BASE_URL', $modx_base_url);
            }
            ... ...
            if (!defined('MODX_ASSETS_PATH')) {
                $modx_assets_path= $realpath_install_dir .DIRECTORY_SEPARATOR. 'assets' .DIRECTORY_SEPARATOR;
                $modx_assets_url= '/assets/';
                define('MODX_ASSETS_PATH', $modx_assets_path);
                define('MODX_ASSETS_URL', $modx_assets_url);
            }


            core/config/config.inc.php, connectors/config.inc.php, /config.inc.php (this is silly, why are there so many config.inc.php lol? ... When i think of a config file, i think of 1 file, not 3/4 separated places ... like Drupal's settings.php):
            <?php
            $current_dir = dirname(__FILE__);
            //error_log('manager1/:'.$current_dir);
            $install_dir = $current_dir .DIRECTORY_SEPARATOR. '..' .DIRECTORY_SEPARATOR;
            //error_log('manager2/:'.$install_dir);
            $realpath_install_dir = realpath($install_dir);
            //error_log('manager3/:'.$realpath_install_dir);
            $core_path = $realpath_install_dir .DIRECTORY_SEPARATOR. 'core' .DIRECTORY_SEPARATOR;
            //error_log('manager4/:'.$core_path);
            
            
            define('MODX_CORE_PATH', $core_path);
            define('MODX_CONFIG_KEY', 'config');
            ?>
            [ed. note: armyofda12mnkeys last edited this post 13 years ago.]