Pushing files to domains?

software development

#1

I’m trying to build a system that will allow me to administer multiple sites from another site. Basically I want to be able to “broadcast” file changes from the main site to the other sites via FTP without having to open each one manually and upload the files…over and over again.

I’ve been doing ecommerce stuff and I’ve seen how you can connect directly to a payment gateway using curl or fsockopen. Is this the same principle?

All these domains are hosted on Dreamhost, I’ve got them set up under different users.

Any help would be appreciated!

================================
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#2

Try rsync. It uses SSH (each user account will need SSH access) to sync up sites and can be set to delete. You’ll just need one master and rsync can do the rest.


yerba# rm -rf /etc
yerba#


#3

Do I need to physically set up each domain, or can I do that dynamically? For example, if I have a db table that stores FTP usernames and pw, can I run a query to connect to them using rsync from the master?

================================
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#4

You will have to setup each domain. You’ll also need to setup SSH keys to allow rsync to connect w/out a password prompt. It’s actually a bit of a setup, all manual. How comfortable are you on Linux?


yerba# rm -rf /etc
yerba#


#5

If you’re writing in php, you could use curl or Fopen to pull the content from your main site. You can set up the layout for each website, and just pull the actual content from the php file(s) where you update. (Fopen will work here, it’s only urls that you can’t use with it - as long as your sites are all on the same box just reference the file like /home/username/example.com/content.php)

I’m sure others could help you with specific coding here, though past the concept I don’t know much here.

–Matttail
art.googlies.net - personal website


#6

Mattail,
I was actually sort of thinking in the same direction. I looked around, there are about a billion cURL scripts on the net. What I need to do is pull the ftp username and pw from the db on my main site, then connect to the remote site and upload a file from the main site to the remote site.

Currently I’m getting an access denied error. The username and pw is correct, I’m using it with CuteFTP Pro just fine.

Any ideas?

================================
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#7

Username and/or password is not getting pulled properly from the DB. You certain it’s 100% correct within the variables in your script?


yerba# rm -rf /etc
yerba#


#8

Do you need to involve FTP in the equation? You could even just use ‘phpinclude’ to pull the relvent pages in. You can style your pages differently and whatnot, then just call in your php file that you’re updating.

For instance, main.php would have all the real content - your products or news posts or whatever. Then your index.php files on each domain or subdomain can set up their differnet styles, have any indeividual content you want, and call in main.php and display that. You don’t need FTP at all for that.

I assume that your sites are all slightly differnet, you’re not just looking to mirror the main domain right? Someitmes I overlook the obvious and feel stupid in the end. Sometimes I point out the obvious and you think I’m stupid. But there it is anyways. :slight_smile:

–Matttail
art.googlies.net - personal website


#9

I had considered that too. I have two scenarios…setting up a site initally and then maintaining it once it is set up.

In the first scenario, using FTP really works for me. I’m lazy, I don’t want to FTP into an individual site if I can press a button and have it happen for me. I’m going to have a lot of these sites, quick setups are crucial.

The second, where I could potentially be updating a site, I did consider just doing an include. But I’d have to use curl for it because the main file is off the server (it’s still with DH, just on a different server/domain/username). However, because we are talking about a lot of sites, I was concerned about the bandwidth usage.

Which in your opinion is better? To waste the bandwidth by hotlinking to the include file, or to have a copy on each domain and waste disk space?

No, they are all slightly different, but the different stuff is all pulled from the db, so they are essentially the same from the server view.

I don’t think that was a stupid thought, it confirms where I was trying to go with this whole thought process. I need a decent, scalable solution and thanks to your thoughts, I think I’ll be able to figure one out. So thank you.

================================
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#10

[quote]Which in your opinion is better? To waste the bandwidth by hotlinking to the include file, or to have a copy on each domain and waste disk space?

[/quote]

Well, for me anyways, both bandwidth and storage are effectivly unlimited - so it doesn’t make a difference. Just go with the solution that is easies for you and your setup. Either way, just how much content are you going to be sharing between the sites? php files are really small, what’s a few mb for every page load when your bandwidth is in Terabites and storage is in GB?

Becuase the traffic to hotlink the file is still all within the DH network I don’t see that you’d notice any transfer lag. Though I suppose that if your ‘primary’ server were to go down that means all your other sites go down even if they’re on a different machine. I guess keeping several copies might reduce downtime - but I’m not sure that’s much to worry about.

I remember only a few years ago I had hosting with a differnet company and I had to watch my limit becuase I only had like 500mb of storage, and 10 GB of transfer. So I suppose that in a few years I may not think that what I have now in ‘unlimited’ but if it keeps growing every week - who knows.

So, in the end I think you should go for the system that makes the most sense to you. Personally I’d go with php includes or curl. It just makes more sense to me, having site layout cookie-cutter style, pull content from one place you update. That makes it wasy to push out lots of sites fast, make small changes to each as you need, and have one spot to update content.

With your setup would it make things easier, and or is it possible to ask support to move you so everythign is all on the same server?

–Matttail
art.googlies.net - personal website


#11

Instead of pulling data from another website. Why not allow each website to share the same database? The database could have a field that determines which website the data belongs to. Example: 1 for website 1, 2 for website 2, 3 for website 1 and 2.
Just a thought,
Silk


#12

The websites already are sharing one db. All the dynamic data is already in one central db location.

However, there are a few images on each site that are different, my quandry was whether I should push them to the different domains, or just hotlink from the main site.

Speaking of which, if I do hotlink I don’t want people stealing my pics. I know there’s a feature on the panel to restrict where you can hotlink from. Can I use the servername there instead of a domain? Most of these are currently on shnooky, so setting up one server to link from would work.

================================
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com


#13

I guess my biggest concern was that if I had a lot of these sites I didn’t want to start using up a lot of CPU. Which I think hotlinking would probably use more than having the file local, but I’m just guessing there.

I could probably have them moved to the same server, but I’m using 2 accts and the main domain is on a different one. My Dad was kind enough to allow me to plunder his disk space, but the main domain is on my acct.

================================
CrimsonDryad Web Design Services
Web Design, Custom Software Development
http://www.crimsondryad.com