Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter thomashong

    (@thomashong)

    **** getting an error trying to submit a reply — please delete if duplicate ****

    Hi @danielbachhuber,

    I tried and this is what happens…

    The current “core” wp-config.php (WITHOUT code block):

    <?php
      /* this WordPress install is configured for multitenancy */
      include_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
    ?>

    THEN is the same error message:
    Error: Strange wp-config.php file: wp-settings.php is not loaded directly

    IF I ADD what you suggest to the “core” wp-config.php like this:

    <?php
      /* this WordPress install is configured for multitenancy */
      include_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
    
      /** Sets up WordPress vars and included files. */
      require_once(ABSPATH . 'wp-settings.php');
    ?>

    Then I get this new error message:

    PHP Warning:  include_once(/opt/wordpress/4.7.3/wp-config.php): failed to open stream: No such file or directory in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(982) : eval()'d code on line 2
    PHP Warning:  include_once(): Failed opening '/opt/wordpress/4.7.3/wp-config.php' for inclusion (include_path='phar:///usr/local/bin/wp/vendor/phpunit/php-token-stream:phar:///usr/local/bin/wp/vendor/phpunit/phpunit-mock-objects:phar:///usr/local/bin/wp/vendor/phpunit/php-code-coverage:phar:///usr/local/bin/wp/vendor/phpunit/phpunit:phar:///usr/local/bin/wp/vendor/symfony/yaml:.:/usr/share/php') in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(982) : eval()'d code on line 2
    Error: Error establishing a database connection. This either means that the username and password information in your 'wp-config.php' file is incorrect or we can’t contact the database server at 'DB_HOST'. This could mean your host’s database server is down.

    On each “tenant” install, I already have that code block. wp-config.php is:

    <?php
    
    ...
    
    /** WP multi-tenant */
    define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
    define('WP_SITEURL', WP_HOME . '/wp');
    define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/content' );
    define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
            define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    Thread Starter thomashong

    (@thomashong)

    Hi @danielbachhuber,

    I tried and this is what happens…

    The current “core” wp-config.php (WITHOUT code block):

    <?php
      /* this WordPress install is configured for multitenancy */
      include_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
    ?>

    THEN is the same error message:
    Error: Strange wp-config.php file: wp-settings.php is not loaded directly

    IF I ADD what you suggest to the “core” wp-config.php like this:

    <?php
      /* this WordPress install is configured for multitenancy */
      include_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
    
      /** Sets up WordPress vars and included files. */
      require_once(ABSPATH . 'wp-settings.php');
    ?>

    Then I get this new error message:

    PHP Warning:  include_once(/opt/wordpress/4.7.3/wp-config.php): failed to open stream: No such file or directory in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(982) : eval()'d code on line 2
    PHP Warning:  include_once(): Failed opening '/opt/wordpress/4.7.3/wp-config.php' for inclusion (include_path='phar:///usr/local/bin/wp/vendor/phpunit/php-token-stream:phar:///usr/local/bin/wp/vendor/phpunit/phpunit-mock-objects:phar:///usr/local/bin/wp/vendor/phpunit/php-code-coverage:phar:///usr/local/bin/wp/vendor/phpunit/phpunit:phar:///usr/local/bin/wp/vendor/symfony/yaml:.:/usr/share/php') in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(982) : eval()'d code on line 2
    Error: Error establishing a database connection. This either means that the username and password information in your 'wp-config.php' file is incorrect or we can’t contact the database server at 'DB_HOST'. This could mean your host’s database server is down.

    On each “tenant” install, I already have that code block. wp-config.php is:

    <?php
    
    ...
    
    /** WP multi-tenant */
    define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
    define('WP_SITEURL', WP_HOME . '/wp');
    define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/content' );
    define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
            define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    Thread Starter thomashong

    (@thomashong)

    Yes. Same error.

    Thread Starter thomashong

    (@thomashong)

    Gotcha, thanks! I have version 1.1.0. Tried what you suggested and no go.

    To confirm WP-CLI works (it is a new installation), I did another test on a clean WP test site and is fine. This is a standard WP installation with core files, wp-contents, etc. in the usual places. I can do “wp plugin list” or “wp user list”.

    Staring at the error message, it’s specifically saying “wp-config.php” file. On a multi-tenant setup:

    WP “core” wp-config.php is:

    <?php
      /* this WordPress install is configured for multitenancy */
      include_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );
    ?>

    WP “tenant” wp-config.php is:

    <?php
    ... same as a normal setup except ...
    
    define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
    define('WP_SITEURL', WP_HOME . '/wp');
    define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/content' );
    define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
    
    /* That's all, stop editing! Happy blogging. */
    Thread Starter thomashong

    (@thomashong)

    hmm… not much of a choice. Could move it under Everything else WordPress. I just didn’t think it was a “WordPress” problem. If there was a subforum for all things WP-CLI that would be ideal.

Viewing 5 replies - 1 through 5 (of 5 total)