1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiple Sites, Pulling from one database?

Discussion in 'Blogging' started by playercool, Jan 4, 2010.

  1. playercool

    playercool Junior Member

    Joined:
    Jan 4, 2009
    Messages:
    159
    Likes Received:
    31
    I am wondering. So I don't overload my server storage can I pull all the data from RSS feeds to one database? Then set up each Wordpress blog to pull from that same database?

    Doing this I could build a clone of all the RSS feeds I find really quickly and populate multiple sites with ease.

    Is this possible? If so how do you do it?
     
  2. FarmTeam

    FarmTeam Junior Member

    Joined:
    Jun 27, 2009
    Messages:
    139
    Likes Received:
    79
    As long as the table structure is the same you should not have any issues.

    You will need to set up mysql to accept connections from one server to the next, by default I believe only localhost is enabled

    You will have to alter your conf file as well to select that db instead of the local one for your remote blogs
     
  3. playercool

    playercool Junior Member

    Joined:
    Jan 4, 2009
    Messages:
    159
    Likes Received:
    31
    On the wpconfig file I would only change the database name correct? I would leave the username as the username for the new website?

    I tried changing it to mirror the site I am trying to copy and it made the url blank. So if I visit the copied site it is just a blank page. If I try to login to the site: www.copiedsite.com/wp-login.php it takes me to the site I am copying instead. I changed the database, user, password. Left localhost the same.
     
  4. judson

    judson Power Member

    Joined:
    Nov 29, 2009
    Messages:
    530
    Likes Received:
    319
    Occupation:
    Fulltime Newbie IM
    Location:
    Sub Ubi
    I depends what you are trying to achieve.

    If you want to serve all the wordpress sites from one database, there are methods to do this.

    What it sounds like you are trying to do though is slightly different. There is no point in pulling all your rss feeds into one database, and then pulling all your WP sites from it, since most of the RSS to feed plugins will re-store those same feeds as posts into your individual WP databases.

    Maybe I missed the trick, but if you post a bit more on what you are trying to achieve exactly, I might be able to help.
     
  5. playercool

    playercool Junior Member

    Joined:
    Jan 4, 2009
    Messages:
    159
    Likes Received:
    31
    I will try to explain this a little more.

    1. I want to build maybe 10, maybe 100, maybe even 1000 of the identical site. I will change the theme up so they don't all look identical, however they will all have the exact same information. These sites will be populated using RSS feeds that I get from other huge websites. Think mashget type sites.

    2. If you have ever built a site like this you know it ends up taking up TONS of space on your server. So imagine building 10 or a 100 or even 1000 of this same site. You would end up needing dozens of servers to host all this information. At the very least you would need a ton of ram and storage space all of which is very expensive. My goal instead is to have only one database filled with this information and then serve it to multiple sites. Doing so would allow me to only need one server and thus save me tons of money in hosting expense.

    3. As mentioned before I changed the wpconfig file but it messed the clone site up. So clearly I am not doing something correctly.

    Hopefully that helps clear up what I want to achieve. It seems like it would be very doable.
     
  6. judson

    judson Power Member

    Joined:
    Nov 29, 2009
    Messages:
    530
    Likes Received:
    319
    Occupation:
    Fulltime Newbie IM
    Location:
    Sub Ubi
    There are two main WP 'methods' ...

    One is to run *all* your WP sites from one installation of WP. It makes it easier to manage things like plugins and updates. The only thing individual to each installation really, is the config file. The trick here is to get the config file to point to a different table-prefix for each site. So, you have one database, but each of your sites has a unique table prefix. You do not save space, but you save on management time.

    The second is to have one WP database for several sites, serving exactly the same content. Not sure why you would want to do this though. An easy solution would be to have the config file in each WP installation all point to the same database. The problem is that a lot of the settings are saved in the DB. So, if you wanted to run different themes on each of your WP installation, you would create a *different* theme for each site, but call it the *exact same thing*. That way, the master database would be calling *theme#1" which happens to be different for each site. It gets messy though if they have different widgets and the like, and might be useful only as an academic excercise to test the same content with different themes ...

    The third option, is where you start growing hairs on your back, and you have your WP installations share some tables and not others. It gets really messy really quickly though, and from your question, you are not quite ready to go this route though.

    YMMV.

    Hosting and storage are so cheap now though, that if you are looking for exotic solutions, you should be making enough to afford a really good VPS for less than $20 per month, that will happily chug along with over 100 WP sites. Few of us here are serving *that* many pages that you need to start coming up with exotic replication and optimisation solutions.
     
  7. cagefighter

    cagefighter Junior Member

    Joined:
    Nov 13, 2009
    Messages:
    109
    Likes Received:
    101
    Occupation:
    Retired Professional Fighter, Now Trainer and Web
    Location:
    New York/Atlanta
    Yes! I do this on many sites.

    when doing your config file though and the database info
    you need instead of localhost the ipaddress
    then username and password of course

    Google it there is many blogs explaining how to do it, cause many people do this.
     
  8. judson

    judson Power Member

    Joined:
    Nov 29, 2009
    Messages:
    530
    Likes Received:
    319
    Occupation:
    Fulltime Newbie IM
    Location:
    Sub Ubi
    Looks like we cross posted, but see solution #2 on my post above.

    You do not need to change your wp config file at all. Nothing. Just replicate it from one site to the next. Since you want to change the look, and nothing more, see the post above. Make sure each installation is identical. Use different templates for each site, but make sure that each one is called the *exact* same thing.

    That's should be all.
     
  9. judson

    judson Power Member

    Joined:
    Nov 29, 2009
    Messages:
    530
    Likes Received:
    319
    Occupation:
    Fulltime Newbie IM
    Location:
    Sub Ubi

    Works fine in theory, but it will depend on your host's policy. Most places for example, will only allow scripts to have DB access from localhost, so you would need to have all your sites on the same server.

    That said, the cagefighter is right, and you need to point the individual installations to the same database server.

    Again, YMMV...
     
  10. playercool

    playercool Junior Member

    Joined:
    Jan 4, 2009
    Messages:
    159
    Likes Received:
    31
    So far I am having zero success: I am clearly doing something wrong so I will post here what I am doing:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define ('WP_CACHE','true');
    define('DB_NAME', 'site_hello');

    /** MySQL database username */
    define('DB_USER', 'site_hello');

    /** MySQL database password */
    define('DB_PASSWORD', 'sitepw');

    /** MySQL hostname */
    define('DB_HOST', 'localhost');

    Alright so those are the settings of the site I am trying to copy. I used those exact same things on the clone site. Doing so has made the clone site www.clonesite.com just be a blank white page. When I go to www.clonesite.com/wp-login.php it takes me to the site I am trying to copy.

    Am I putting something wrong in the dbusername and dbname area? I tried changing localhost to the IP and it didn't do anything. These are both on the same VPS.
     
  11. judson

    judson Power Member

    Joined:
    Nov 29, 2009
    Messages:
    530
    Likes Received:
    319
    Occupation:
    Fulltime Newbie IM
    Location:
    Sub Ubi
    Have you got an identical file structure for the clone site??

    Everything, including the plugins used, and the themes must be the same. Make sure you have the current theme on the clone site. Sounds like that is what might be the problem.

    The thing with this setup, is that when you log into the admin, you are accessing the database for *all* the sites.
     
  12. judson

    judson Power Member

    Joined:
    Nov 29, 2009
    Messages:
    530
    Likes Received:
    319
    Occupation:
    Fulltime Newbie IM
    Location:
    Sub Ubi
    To add ...

    #1 in my post, allows you to run the same WP install with multiple databases. Upgrading WP files means you only do it once. Since each site, running on the same files has a different DP, they can have different plugins enabled, different themes set up in the DB etc. The advantage is that you only need to maintain one installation of WP.

    #2 above, which is what you have, requires that each of your sites share the exact same file structures. The advantage is they all share the same content. The disadvantage, for example is that if you add a new plugin to your master site, you need to copy that plugin folder to each of your clone sites.

    Each method has its strengths and weaknesses.

    I need to stress this. Even if you want a different theme on each site, you need to make sure that your theme name is the same on each site. The fact that you can log into admin, means the wpconfig.php file is the same. The problem will be plugins or themese missing from your clone site's file structure.
     
    • Thanks Thanks x 1
  13. zone69

    zone69 Junior Member

    Joined:
    Nov 24, 2008
    Messages:
    196
    Likes Received:
    1,290
    Issue I think you are having is due to the wordpress URL being stored in the database. It's in options tab le and occurs once for the siteurl and once for the home.

    I think you can get around this by overriding the setting in wp_config.php with something like:
    Code:
    define('WP_HOME','http://clonesite.com');
    define('WP_SITEURL','http://clonesite.com');
    

    Now the other issue I see is that the guid field in the posts table has the domain name in each post URL of where the blog was created. I'm not sure there is anything you can do about this or if the fix above takes care of that. Give it a try.


    Good Luck!