db connection error for apex domain when WP installed at subdomain
-
Hi, issue is only at apex domain of network primary site (subdomain networks) when network is set up at 1st lvl subdomain.
WP installed at a subdomain, like: https://x.example.tld – secondary networks also set up to use subdomain for primary site (so that new subsites are at like https://subsite.x.example.tld).
If there is no site associated with the apex domain, behavior I’d expect would be to redirect like any other ‘new blog’.
Actual behavior appears to be a database connection failure when requesting the apex domain of all networks installed at 1st lvl subdomain.
apache 2.4, php7.2.5, MariaDB 10.2
WP 4.9.5, wp-multi-network 2.2.0WP files are at home/user/public_html/wp/ (SITEURL and HOME values do not include /wp/ path, and htaccess is modified as well so that /wp/ is not seen in the browser bar).
wp-content has been moved to docroot (home/user/public_html/) and renamed using stnd defines in wp-config.php file, which is also located at docroot.
defined multisite constants are like:
===define('SUBDOMAIN_INSTALL', true); define('PATH_CURRENT_SITE', '/'); define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] ); define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] );
===
Database defines, Keys&salts, and other sensitive stuff is in a file outside of docroot and the file is included like following, added at top of wp-config.php
===// DATABASE AND OTHER SECRETS if ( file_exists( '/home/user/configs/settings.php' ) ) { include( '/home/user/configs/settings.php' ); }
===
Database defines are at the top of the settings.php file.Everything is redirected from :80 to :443 (valid certs.)
—
There have been no problems with this until recently when I saw in php error log for the apex domain (example.tld) notices like:
===
PHP Warning: Use of undefined constant DB_USER - assumed 'DB_USER' (this will throw an Error in a future version of PHP) in /home/user/public_html/wp/wp-includes/load.php on line 404 PHP Warning: Use of undefined constant DB_PASSWORD - assumed 'DB_PASSWORD' (this will throw an Error in a future version of PHP) in /home/user/public_html/wp/wp-includes/load.php on line 404 PHP Warning: Use of undefined constant DB_NAME - assumed 'DB_NAME' (this will throw an Error in a future version of PHP) in /home/user/public_html/wp/wp-includes/load.php on line 404 PHP Warning: Use of undefined constant DB_HOST - assumed 'DB_HOST' (this will throw an Error in a future version of PHP) in /home/user/public_html/wp/wp-includes/load.php on line 404
===
…and when I navigate to the apex domain it displays the good ‘ol
===
Error establishing a database connection
===Issue remains with Twenty Seventeen and removing all plugin files (except wp-multi-network). Also moved all four database defines to top of wp-config.php for good measure, issue remains.
Issue does not occur when wp-multi-network files are removed.
I have done network setups like this before, and feel like I would have noticed this… I think this may be associated with recent update.
When wp-multi-network files are back in place and the plugin is active, I can then use Mercator to make an alias using the apex domain and everything works as expected (except, oddly I got a 503 server error page when I first saved the alias – just closed that browser tab, opened a new one and everything worked).
I assume that using WP native domain mapping to set a network subsite to use apex domain would also work, haven’t tested.
I haven’t tried looking at code, or doing more testing yet… figured I’d just submit this now.
Cheers, Max
ps. will prob also post an issue at the github repo if I can figure out anything more substantial… ??
- The topic ‘db connection error for apex domain when WP installed at subdomain’ is closed to new replies.