• Hello all,
    I'm trying to migrate to multisite, but am getting a server error. There is no log file under the wp-content directory even though I added the following to the wp-config.php:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);

    For starters, I added the following line to wp-config.php:
    define('WP_ALLOW_MULTISITE', true);

    Then, I went through the UI to Tools->Network Setup and did exactly what was listed.

    I added the following lines to wp-config.php:

    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', false );
    define( 'DOMAIN_CURRENT_SITE', 'mysite.com' );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );

    Then, I changed the contents of .htaccess to:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    </IfModule>

    I'm not entirely sure if the code should be within the if tags, but I've played with removing them. That did not make a difference.

    I tried to load the site. I received the following:
    Error: Server Error
    The server encountered a temporary error and could not complete your request.
    Please try again in 30 seconds.

    Needless to say, waiting 30 seconds did not fix the issue.

    I, then, combed through the database. I ran the following SQL stmts, but wound up making no changes, because I believe the result sets were correct:

    select option_value from wp_options where option_name='siteurl';
    https://mysite.com

    select option_value from wp_options where option_name='home';
    https://mysite.com

    select domain from wp_site;
    mysite.com

    select meta_value from wp_sitemeta where meta_key='siteurl';
    https://mysite.com/

    select domain from wp_blogs;
    mysite.com

    I, then, double-checked to make sure that WP_HOME and WP_SITEURL are not defined in the wp-config.php. They were not defined.

    I've even tried restarting the Apache server, even though I'm sure it's not needed. I ran the following:
    sudo systemctl restart apache2.service

    What have I missed? And why can I not find the log file?

    • This topic was modified 2 weeks, 2 days ago by sgt621.
    • This topic was modified 2 weeks, 2 days ago by sgt621.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter sgt621

    (@sgt621)

    I should note that my plugins are inactive, but I have noticed an issue with permalink. It looks like it’s on the right setting, but I don’t believe it’s working properly. Here is a sample link to editing a post (I’ve changed the domain, so you won’t be able to follow the link.):

    https://mysite.com/wp-admin/post.php?post=17&action=edit

    Here is my SQL:

    mysql> select * from wp_options where option_name=’permalink_structure’;
    +———–+———————+——————————————-+———-+
    | option_id | option_name | option_value | autoload |
    +———–+———————+——————————————-+———-+
    | 28 | permalink_structure | /blog/%year%/%monthnum%/%day%/%postname%/ | yes |
    +———–+———————+——————————————-+———-+

    • This reply was modified 2 weeks, 2 days ago by sgt621.
    • This reply was modified 2 weeks, 2 days ago by sgt621.

    Hi!
    Looks like an error in your .httaccess (or someplace else) is keeping WordPress from loading; it never gets that far and so the debug log doesn’t get generated. The wp-debug log is only for errors from within the WordPress system.

    Your .htaccess syntax checks out clean here: https://www.htaccesscheck.com/check.cgi but there may be some other issue with it – assume you only posted a snippet.

    This might be helpful as well: https://www.hostknox.com/knowledgebase/529/How-to-enable-and-install-a-multisite-network-in-WordPress.html

    It’s always a slog getting your first multisite set up!

    Thread Starter sgt621

    (@sgt621)

    Hi,

    Thanks for your reply. I actually removed the logfile generation from the if clause. So, now, the code unconditionally creates a log file. I also introduced a bug and verified that the log file is generated, then I removed the bug.

    And that actually was my entire .htaccess file listed above.

    I followed the link that you listed. I cannot find anything they are doing that does not match what I am doing. I also added the following lines to wp-config.php, but there is still nothing being logged to wp-content/debug.log:

    define( 'SCRIPT_DEBUG', true );
    define( 'SAVEQUERIES', true );
    define('WP_DEBUG_DISPLAY', true);

    FYI, if I remove the changes from the wp-config.php file, I can get the webapp to load. I don't know if that means the .htaccess file is correct or if the file is ignored without a multisite config in wp-config.php.

    Also, the error appears to be 502 Bad Gateway. I am running on GCP (Google Cloud) and am responsible for managing the gateway myself, but why would changing to multisite affect the gateway? Maybe something else is misconfigured somewhere.

    Please let me know if you have any thoughts.


    Is this an existing WordPress install that you are trying to convert to Multisite? Or a new Multisite install? Can you share the URL?

    Is this server error still happening?

    I tried to load the site. I received the following:Error: Server ErrorThe server encountered a temporary error and could not complete your request.Please try again in 30 seconds.

    I am unclear on how you could introduce a WordPress bug if you cannot load your site. Would you paste in the data from your debug.log?

    Could you verify whether or not you see the front end of the site? Can you log into the backend?

    But agreed, since it’s on Google Cloud it might be something specific to that configuration.




    Thread Starter sgt621

    (@sgt621)

    Existing WordPress site. I am currently converting it to multisite.

    There is nothing logging to debug.log, even though it is working.

    https://samgcom.com

    If I take the multisite config out of wp-config.php, it works just fine. If multisite is configured, I cannot see the front end, but I can access the backend — all the files and the DB.

    Thread Starter sgt621

    (@sgt621)

    So it looks like the error message is a standard GCP load balancer error message that you get when your server isn’t healthy.

    Thread Starter sgt621

    (@sgt621)

    That would make sense if it never worked, but it’s been working for months without multisite. It’s been working on https with the domain name and certificate for a few months now. I will look through that thread though. Maybe I’ll find something.

    FYI, I just went through the debug.log -- the timestamp is set to GMT:


    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "HTTP_HOST" in /var/www/html/wp-includes
    /ms-settings.php on line 57
    [09-Nov-2024 04:07:11 UTC] PHP Deprecated: stripslashes(): Passing null to parameter #1 ($string) of
    type string is deprecated in /var/www/html/wp-includes/ms-settings.php on line 57
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "host" in /var/www/html/wp-includes/cano
    nical.php on line 716
    [09-Nov-2024 04:07:11 UTC] PHP Deprecated: strtolower(): Passing null to parameter #1 ($string) of t
    ype string is deprecated in /var/www/html/wp-includes/canonical.php on line 716
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "host" in /var/www/html/wp-includes/cano
    nical.php on line 727
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "host" in /var/www/html/wp-includes/cano
    nical.php on line 730
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "scheme" in /var/www/html/wp-includes/ca
    nonical.php on line 751
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "host" in /var/www/html/wp-includes/cano
    nical.php on line 716
    [09-Nov-2024 04:07:11 UTC] PHP Deprecated: strtolower(): Passing null to parameter #1 ($string) of t
    ype string is deprecated in /var/www/html/wp-includes/canonical.php on line 716
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "host" in /var/www/html/wp-includes/cano
    nical.php on line 727
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "host" in /var/www/html/wp-includes/cano
    nical.php on line 730
    [09-Nov-2024 04:07:11 UTC] PHP Warning: Undefined array key "scheme" in /var/www/html/wp-includes/ca
    nonical.php on line 751

    That’s your problem – your http_host header can’t be detected.

    From chatgpt:

    In a single-site configuration, WordPress doesn’t rely on HTTP_HOST and other array keys to the same extent as it does in a multisite setup. Here’s why the issue is specific to multisite mode:

    1. Multisite’s Dependency on HTTP_HOST for Domain Mapping:
      • In a single-site setup, WordPress primarily uses the siteurl and home options from the database to determine the site’s URL. It doesn’t need to dynamically map multiple domains or subdomains, so HTTP_HOST is not as critical.
      • In a multisite environment, HTTP_HOST is crucial because WordPress uses it to identify the correct subsite based on the incoming request’s hostname. Without this information, it can’t map the request to the correct subsite, leading to PHP warnings and failed requests.
    2. Increased Complexity of Multisite Network Configurations:
      • Multisite setups introduce more complex routing rules that require PHP to access and interpret incoming headers to route users to the right subsite or subdirectory. The configuration of ms-settings.php and other WordPress core files relies heavily on HTTP_HOST, REQUEST_URI, and sometimes HTTPS headers to function correctly.
      • When these headers are missing or not populated correctly, the multisite configuration cannot route requests properly, resulting in 502 errors.
    3. Canonical Redirects and URL Rewriting:
      • Multisite networks need to handle canonical URLs to enforce consistent URLs across the network, which is managed in canonical.php. These canonical redirects rely on HTTP_HOST, REQUEST_URI, and scheme headers to determine the correct URL structure.
      • Without these headers, canonical.php cannot correctly form URLs, triggering undefined array key warnings and causing the server to drop requests, which often leads to a 502 error.
    4. Server Configuration Requirements for Multisite:
      • Multisite often requires specific web server configurations or proxy settings to handle and pass headers properly, particularly in environments using load balancers or reverse proxies (common in GCP). In a single-site setup, these specific configurations are usually not as necessary.
      • If your server or load balancer configuration doesn’t account for the multisite requirements (such as forwarding headers like Host and X-Forwarded-Host), the environment won’t work as expected when switching to multisite.
    5. Dynamic Path and Domain Resolution:
      • Multisite mode introduces dynamic path or subdomain resolution, meaning WordPress can serve multiple sites from a single install. For that, it heavily relies on ms-settings.php, which parses these headers to determine the current site context. If these headers are unavailable, multisite cannot function, but single-site mode can continue since it doesn’t need this resolution logic.

    In summary, the multisite setup introduces dependencies on server and network configurations that are unnecessary in a single-site setup. When these configurations are missing or incomplete, multisite-specific files like ms-settings.php and canonical.php generate errors, leading to 502 failures that wouldn’t appear in a single-site environment.

    Possible solution:

    GCP environments often use proxy layers or load balancers, which may need specific settings to handle headers correctly.
    Solution: In GCP Console, confirm that X-Forwarded-Host, X-Forwarded-Proto, and Host headers are properly forwarded. You may need to set up your web server to recognize and correctly handle these headers.

    Thread Starter sgt621

    (@sgt621)

    I think you’re right! I have not configured these. Let me play with the configuration and get back to you. Thanks for all your help!

    Thread Starter sgt621

    (@sgt621)

    @bigtomato BTW, what did you use to hit the browser last night? I posted my response to you and left my seat for a few minutes. That’s about when the error messages appeared in the log file. I’ve been using Chrome, but haven’t been able to generate anything in the logs.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.