Solved

Website Cloning or Mirroring across multiple domains?

Posted on 2009-07-02
7
208 Views
Last Modified: 2013-12-13
I have a website called globallistings.com (fictional), it is a business directory for multiple cities.
This search able online database is built in php , it only uses cookies and does not use sessions to share member info.

I want this website on various servers and share the same mysql data and user image uploads across multiple domains.

Domains For example use:

losangeleslistings.com;
chicagolistings.com;
newyorkcitylistings.com;

when the user goes to his city, he will see a custom website and graphics for his city that shares the same mysql data and user image uploads across all domains.

The main goal is to have many websites for different cities all sharing same mysql data and user image uploads, but each site having a unique design and domain name.

right now the images folder is located at:   ' globallistings.com /images ';
right now the mysql server is on localhost at globallistings.com

I understand myspace and facebook are also using this same system.

Question #1: What is the best way to accomplish this task?

Question #2: If main server is shut down "globallistings.com" can other websites still operate on separate servers?

Question #3: Do i clone the main mysql server or do i share the data from one mysql server across multiple domains?

Question #4: How do i handle user image uploads?

Thank you for your responses.

0
Comment
Question by:zefex
  • 3
  • 3
7 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Well, that is four questions and we usually answer one question at a time, so I will take a crack at Q#2.

If you have a central server that has your images, and it goes away, your images go away.  So you would probably want to go with a content server like Akamai for this kind of application.

If I were going to answer Question #1, I think the answer would have to be given with an understanding of your budget.  In the development phase, I would just write programming that can be partitioned easily, and have all the domains resolve to the same IP address. If this starts to get the kind of traffic that Facebook carries, you will have different issues that are unrelated to PHP - ie, you will need to hire a lot of lawyers and accountants.

If you have more specific questions about any aspect of this, please post back here and I will try to drill down into the technical issues.

Best regards, ~Ray
0
 

Author Comment

by:zefex
Comment Utility
Thank you for your response.
::Update:::
I was able to share the mysql database remotely among the different servers and i was also able to share the images.

I am using one mysql server and one folder and sharing the data remotely to the other servers.

The database is passing the information perfectly, but when the php is reading the image info width x height then passing the images it is too long of a delay taking up to 2 minutes to pass the data of one page that contains 30 images in a list.

Now i am considering using Curl with a cron job to update each database for localy for each server. Is this a efficient method? I will be grabbing the images and the data and storing them localy for each host via cron job set at one minute.

Any tips would be greatly apreciated.

@Ray_Paseur: my budget is $0 dollars.
0
 
LVL 19

Expert Comment

by:NerdsOfTech
Comment Utility
Cron job to compare and update the tables for all of the segregated servers.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:zefex
Comment Utility
@NerdsOfTech

I know mysql has a function to mirror said server it is called 'Replication Server'. I dont know if this is possible , i am on shared hosting with "The planet (hostgator) " i will also need to mirror the folder that contains uploaded pics, unless i move the images to blob in mysql (not convenient)?

If i cannot use the Replication Server function of mysql because i am on shared with "The Planet Hosting" what is the best way to compare tables of my servers?

What is the best way to compare my images folder from each server?
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
"What is the best way to compare my images folder from each server?"

This is really a new question, and I recommend that you post new questions when you have new questions.  Given your budget, I am not sure you can guarantee success on this project, but here is how I would go about checking the images folders.

You might use something like this function to get an array of arrays with information about all the files in the images directory.  Then you can use md5() to create a digested string of this multidimensional array.

Compare the md5() string to the previous md5() string.  If they match, the directory has not changed.  It they do not match, you need to update the images folders on the remote servers.

I would not advise putting images into blobs in the MySQL data base.  There are a lot of reasons to avoid doing such a thing - performance and backup issues are two that come immediately to mind.

If you come to trust your central image server, you might consider just using explicit URLs in your <img src=URL /> statements - they images will be resolved and loaded by the browser.  This is what Akamai will do, but they will be serving your images from a high-speed edge network.

Best of luck with it, ~Ray
function dir_list($dir) // GET AN ARRAY OF ARRAYS OF FILE DATA

{

// MAKE SURE WE HAVE A TRAILING SLASH

   if ($dir[strlen($dir)-1] != '/') $dir .= '/';

   

// RETURN EMPTY ARRAY IF NOT A DIRECTORY   

   if (!is_dir($dir)) { return array(); }
 

// OPEN AND READ THE DIRECTORY

   $dir_handle   = opendir($dir);

   $dir_things   = array();

   while ($thing = readdir($dir_handle))

   {

   

// DISCARD KNOWN DIRECTORY INFORMATION - LOOK AT FILES ONLY   

      if (!in_array($thing, array('.','..'))) 

      {
 

// ACCUMULATE FILE INFORMATION 

         $filename   = $dir . $thing;

         $file_thing = array (

            'name' => $thing,

            'size' => filesize($filename),

            'type' => filetype($filename),

            'time' => date("Y-m-d H:i:s", filemtime($filename))

         );
 

// ADD FILE INFORMATION TO THE RETURN ARRAY

         $dir_things[] = $file_thing;

      } // END IF

   } // END WHILE

   

   return $dir_things;

} // END FUNCTION

Open in new window

0
 

Author Closing Comment

by:zefex
Comment Utility
Thank you, this pointed me in the right direction. Although i could not get the script to work i did write a similiar one using php manual. Thank you!
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points - glad you've got it headed in the right direction.  Best, ~Ray
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now