• Hi. I want to install WordPress on three domains. I use Perl to post to WordPress. I use wordpress::API::post from cpan.org.

    This Perl module does not recognize WordPress sites as it assumes the tables to post are standard. I.e only wp_post. So I cannot use sites.

    What I want to do is to have multiple databases but only one installation of WordPress so that all the sub domains use standard plugins and a theme. I don’t want to install the same plugin three times or propagate a tweak in the team to other installations.

    Is there a way to get WordPress to use different databases based on the domain name while keeping the theme and plugins the same?

Viewing 9 replies - 1 through 9 (of 9 total)
  • There no way you can have one wordpress install and separate database of each domain name.

    You will have to have separate install for each domain if you want each to have its own databse.

    Thread Starter ltcommander

    (@ltcommander)

    Ok, thank you

    You can actually do this by uisng a WordPress Network installation.

    Each site won’t have it’s own seperate database, but it will “segment” each sites database by using a different prefix for each network site, so you can move/copy/whatever the database for one site relatively easily.

    Thread Starter ltcommander

    (@ltcommander)

    The catch I have with that is that the Perl Module I use (WordPress::API::Post) doesn’t recognize sites. I have to either wait for a new PM or try to write a posting function myself.

    Well, are yo any good with PHP? ??

    If you are, there’s a bit of a hacky way of getting around this.

    In your wp-config.php file you will need to add in something like this:

    `if (strpos ($_SERVER [“HTTP_HOST”], “firstwebsite.com”) !== false) {
    define(‘DB_NAME’, ‘database1’);
    define(‘DB_USER’, ‘username1’);
    define(‘DB_PASSWORD’, ‘password1’);
    define(‘DB_HOST’, ‘localhost’);
    }
    elseif (strpos ($_SERVER [“HTTP_HOST”], “secondwebsite.com”) !== false) {
    define(‘DB_NAME’, ‘database2’);
    define(‘DB_USER’, ‘username2’);
    define(‘DB_PASSWORD’, ‘password2’);
    define(‘DB_HOST’, ‘localhost’);
    }
    else {
    define(‘DB_NAME’, ‘database’);
    define(‘DB_USER’, ‘username’);
    define(‘DB_PASSWORD’, ‘password’);
    define(‘DB_HOST’, ‘localhost’);
    }`

    Using something like this you can use a different database connection for each website that you have pointing to that one account.

    This means that there’s still a single code-base but all of the content and the settings will be separated by using the different databases.

    One word of warning because I haven’t tested this myself yet. I am not sure how teh media gallery will work if you upload two files of the same file name on different sites. It should work (should…) but it’s something that I’d advise you test out for yourself.

    Hopefully that might help you out a bit.

    Thread Starter ltcommander

    (@ltcommander)

    I get this. That’s awesome Michael, thanks!! I am a Perl guy but can do some PHP too! I will give this a go!

    so does this work?

    Let us know!

    Thread Starter ltcommander

    (@ltcommander)

    Hi,

    I can’t remember why but I ended up installing separate installations. I think it’s because I use WordPress::API::Post (Perl) to post and that didn’t work with such a set up. So, to get it done quickly, I just ended up installing multiple WordPress installations.

    Moderator bcworkz

    (@bcworkz)

    If anyone is thinking of trying Michael’s hack, it appears to me you might also want to define WP_SITEURL and WP_HOME to equal HTTP_HOST or an appropriate variation. It should work without this, but this would ensure users will not be confused by different domains showing up somewhere.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Multiple domains multiple databases one theme’ is closed to new replies.