I have two servers for a website. One server will have php code and database and another less speed server to store files only. I need to implement these in a way that file uploaded through the website must store at another server and also then can be downloaded from there.
Can anyone suggest me best way to achieve that. I know the files can be transferred to another server by FTP functions of php just after uploading through website but doesn't seems a correct way.
Or two server can be used for static media content like images only.
Thanks
The best idea is to just have ALL the files, including the websites files on the "storage server". Basically what you do is mount the "shared folder", this means the websites files and other files you will be needing. (Most of the times you just have a /var/www-local/ folder on the storage server, which you mount in /var/www/ on the webserver).
Make sure you mount it using NFS by adding it in the /etc/fstab file on the webserver. (More info on NFS)
The advantage of this idea is that when you want to expand, this is easily possible by putting a software loadbalancer (like HAProxy), adding as much webservers as you like and you will have your data in sync.
I've used something called Gluster which allows for things like this. The situation I use it for is more for load balancing than for alternate content distribution.
Also, sites like Stack Overflow use Content Distribution Network services for certain pieces of information on their site. A solution like this might actually be more cost effective than buying/setting up/maintaining a whole new server.
May be you can mount the upload directory to your web server. Check Linux NFS
Don't know if this is the best way, but why not simply have the file server a separate subdomain? That way it can handle all of the file download minutia and you can connect to it via FTP or SFTP from the main server.
Basically, here is a process you could use:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With