I am planing to build a CMS-system.
The CMS system will be located and fully administrated at:
http://www.mycompany.com/customer
The final website will be located at:
http://www.customer.com
I need to figure out the best way to copy files (eg. images)
from: http://www.mycompany.com/customer/media
to: http://www.customer.com/media
Note: The CMS and customer page will be located on different hosts. And I want to build this function using PHP.
Some thoughts:
The optimal solution would be if the two directories could be cloned automaticly, no matter how the images are uploaded or updated. Maby if there is a way to detect changes to http://www.mycompany.com/customer/media, then http://www.customer.com/media could be notifyed about it and send a request to update the image.
A wish would also be that images only could be accessed from http://www.mycompany.com/customer/media if logged in to the CMS :S
Any tips?
You should not use FTP (insecure), or PHP for the replication,
try rsync instead :-
What is rsync ?
http://en.wikipedia.org/wiki/Rsync
In another word, is designed meant for mirroring or replicating (is industry standard)
In general,
What does the cronjob do ?
In nutshell, it should rsync the selected source directory to destination server,
a quick example :-
However, rsync is too hard to describe in few sentences, you can take a look :-
http://www.cyberciti.biz/tips/linux-use-rsync-transfer-mirror-files-directories.html (as a start)
Other possibilities is make use of version controlling software, like -:
Or make use on CDN (like @Amir Raminfar has mentioned), which itself is already a complete solution for file distribution.