We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1331
    • 129 Posts
    I have followed the instructions for creating a mult-domain setup for subdomains using the Contexts feature, as described here
    http://svn.modxcms.com/docs/display/revolution/Creating+a+Subdomain+from+a+Folder+using+Virtual+Hosts

    I’ve followed the directions explicitly, however, for some reason, the browser wants to DOWNLOAD the page instead of displaying it. It’s acting like my server isn’t set up to serve PHP, but ONLY within this directory. Other file types display when called from this folder using the virtual subdomain.

    I even went into my MODx installation and added explicitly defined a Content Type for PHP and it didn’t help.

    I have even tried adding PHP directives to the VirtualHost container:
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    Any ideas?

    Here are my specs.

    Linux server (2.6.9-023stab048.6-enterprise)
    Apache/2.2.3 (CentOS)
    Mysql 5.0.45 (client AND server)
    PDO driver for Mysql: yes
    Gzip enabled
    PHP Version 5.2.6
    PHP running as an Apache module

    PS: Is there any way to set directives for virtual host without having to edit the http.conf file?
      • 1331
      • 129 Posts
      Update: I got the PHP to render by adding the following to my VirtualHost container

      <Directory /var/www/vhosts/domain.com/httpdocs/test>
      php_admin_flag engine on
      <Directory>

      My server (Plesk running on MediaTemple DV) also wanted me to define a port number on the VirtualHost, ie

      <VirtualHost test.domain.com:80>

      Now I just gotta get past the Error 503 I’m getting when accessing the new context.
        • 1331
        • 129 Posts
        After all that hoop-jumping with Apache and PHP modules, I used the method described for using a single Gateway plugin for managing multiple domains. http://svn.modxcms.com/docs/display/revolution/Using+One+Gateway+Plugin+to+Manage+Multiple+Domains

        This also works for subdomains.

        Doing this, I didn’t need access to the Apache config file.
          • 1331
          • 129 Posts
          Ok, somebody’s gotta have an answer for this one: When I put the config.core.php, index.php (modified) and htaccess in a folder named after the virtual subdomain, I continuously get an Error 503.

          The error logs say PHP Fatal error: Call to a member function get() on a non-object in /var/www/vhosts/domain.com/httpdocs/core/model/modx/modx.class.php on line 1235

          Apparently, this is beyond my control. Any help on this would be GREATLY appreciated.
            • 3749
            • 24,544 Posts
            It looks like MODx is having trouble finding the class file for whatever object you’re calling get() on.

            You may need more config.core.php files (or to edit the existing ones). There should be one in the connectors dir, one in the manager dir, and one in the site root,
              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
              • 1331
              • 129 Posts
              Yeah, I tried a bunch of different things and it’s just too much to guess at. I think the devs will have to weigh in on this one.
                • 1331
                • 129 Posts
                I’m going to assume that the documentation needs to be updated, because the context that’s a subdomain mapped to a subdirectory won’t work with just the core.config.php, htaccess and index.php files.

                I’ve (so far) narrowed it down to this: the root core.config.php file setting a core path that matches the directory you’re in, not the core in the root folder.

                As of right now, I can see that the subdirectory context won’t function without the following folders: core/config, core/model, and core/xpdo. And that’s simply for rendering the page. I’m not sure if any other site functions are broken due to any of the other directories that I have not included for this test.

                It seems to me that if we could properly set this in the primary config file, it will simply grab the necessary files from the root directory?

                For the moment, this has everything up and running.
                  • 3749
                  • 24,544 Posts
                  I’ve never done what you’re trying, but can’t you point all the core.config.php files at the same core (using its actual full path) and have them all share it?
                    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
                    • 1331
                    • 129 Posts
                    Oh snap! For some reason I didn’t think to use the full path. I changed the config.core.php in the subdirectory with the following:

                    Change
                    define(’MODX_CORE_PATH’, dirname(__FILE__) . ’/core/’);
                    to
                    define(’MODX_CORE_PATH’,’/path/to/www/core/’);

                    And now, even the GoogleMaps snippet is working for subdomains.

                    Thanks, BobRay for the pointer.