0

I need help with my WP installation.

I have a home server for tests with LAMP and WP. I have created three sites: main.lan, test2.lan and pbtest.lan.

pbtest.lan was installed first, this is a multisite installation with subfolders. It worked perfect. Then I have added two new sites. I have access from another PC, so I have created necessary entries in hosts files on PC and server to have access with domain name. And at this moment problem occured.

Two new sites are working properly, when I put main.lan in the browser I have main.lan site opened. The same with test2.lan. But when I try to open pbtest.lan I see main.lan site. In address bar there is IP address of my server instead of domain name. For main.lan and test2.lan there is domain name in the bar. When I disable two new sites and pbtest.lan is the only one avaliable site it is opened properly.

This is part of wp-config.php file for pbtest.lan site:

    /*Multisite*/
    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', '192.168.1.110');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
     /* That's all, stop editing! Happy blogging. */

     /** Absolute path to the WordPress directory. */
     if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/');

define('DOMAIN_CURRENT_SITE', '192.168.1.110'); I think this line redirects traffic to IP address, and first avaliable site is opened. In my case this is main.lan. When I replaced IP address with domain name pbtest.lan I get error conection with database.

I tried put the full path to the directory, but it didn't worked.

Help, what shell I change to have all sites work?

Thank you

English is not my native language, but I hope you will understand my problem :)

1
  • If pbtest.lan has its own wp-config.php is it not a separate install? Are all these sites on the same WP install in a multisite install? Or is each one an independent install of WP as a multisite? It isn't clear from your question. Also, I'm assuming that you're using Apache as you speak of VirtualHosts? Have you confirmed every domain serves the correct folder regardless of what WP does?
    – Tom J Nowell
    Jan 21 '20 at 14:18
0

I can't comment at the moment (I haven't got enough reputation) so I'm going to try and answer instead.

How did you set up multisite and the three sites? The subdomain URL structure would usually mean that you have a primary site (I think main.lan in your case) and then sites on the network would be a sub-domain of that site (e.g. test1.main.lan, pbtest.main.lan). I can see that define('SUBDOMAIN_INSTALL', false); is false when it should be true, and you're right that DOMAIN_CURRENT_SITE should be a domain and not an IP address.

If you follow the process to configure multisite by going to Tools > Network Setup and selecting the sub-domains option, it should give you the necessary rules to add to your .htaccess There's more on multisite setup here

For the three addresses, you have mentioned, to work, I think you would need to setup a site as http://lan and then have the other sites as subdomains of it.

There are ways of having any custom domain mapped to a site on a WordPress multisite network, and that might be the solution here. You used to have to use a plugin, but for some time it's been in the core of WordPress and you can edit the 'Site Address (URL) field' in the network admin to the custom domain that you want to use.

I'm not confident that this has answered your question. If it has, great, but otherwise, I hope it gets you a step closer to the solution.

0

Thanks for answeres.
This are three independent WP installations. Every installation has of course its own wp-config.php file. test2.lan and main.lan sites are typical singlesite, installation connected to pbtest.lan domain is configured as multisite with subfolders, not subdomains. This is why in config I have

define('SUBDOMAIN_INSTALL', false);

Subfolders are working correctly, so I have separate sites pbtest.lan/user1, pbtest.lan/user2. Domains main.lan and test2.lan are separated from pbtest.lan.
So, multisite configuration itself is working, two separate domains are working. The only problem is when I put pbtest.lan in the browser it redirects me to the main.lan site.
OK, I know why. In config file there is IP address of my server and main.lan is the first site. But I don't know what should I do to have access to pbtest.lan.

Have you confirmed every domain serves the correct folder regardless of what WP does?

Yes, it's checked. I moved whole WP installation to another folder and placed a simple html file instead. It was opened corectly, problem is in WP configuration.

0

OK, I solve the problem :)
There were three entries in MySQL database with IP address. Two in table wp_options (siteurl and home) and one in table wp_blogs. For singlesite installations it is easy to change it direct in WordPress settings, but for multisite it's not possible. Also wp-config lines

define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );

didn't overwrite IP address.
So if you would like to install WP multisite first change IP to URL in Settings, then then turn on multisite :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.