Welcome Guest, Not a member yet? Register   Sign In
Logic help with multiple sites .
#1

[eluser]Twisted1919[/eluser]
How would you proceed if you need to have more sites on same server and all of these would be controlled from same place, but every site will have it's own domain name therefore other vhost?
I am facing this problem and i have some ideas but i need to know others opinion , maybe some of you already faced this .

I can even use different CI installs for each website , if it's the case .

Any ideas ?
#2

[eluser]theprodigy[/eluser]
What exactly do you mean by "controlled from same place"? Are you talking about a single admin interface?

My current setup has multiple sites on same shared hosting plan, each with their own domain. All of them are sharing the same System directory, but each have their own Application directory and separate public_html directories. But, they don't share admin back-end control or anything. I did have a plan to set up a single admin interface, but have not done it yet.
#3

[eluser]Twisted1919[/eluser]
Yes , same admin interface .
Could you give more details about your idea ?
Maybe few details on how you achieved your current setup ?
#4

[eluser]theprodigy[/eluser]
my current directory structure is:
Quote:application
|---site_1
|---config
|---controllers
|---models
|---views
|---etc, etc
|---site_2
|---config
|---controllers
|---models
|---views
|---etc, etc
|---site_3
|---config
|---controllers
|---models
|---views
|---etc, etc
system
|---cache
|---codeigniter
|---etc, etc
public_html
|---site_1
|---index.php (points to application/site_1 and system)
|---css
|---js
|---images
|---site_2
|---index.php (points to application/site_2 and system)
|---css
|---js
|---images
|---site_3
|---index.php (points to application/site_3 and system)
|---css
|---js
|---images

My idea was to set as much for each site as I could into configuration settings stored in the site databases. Also set as much other stuff as possible (data, maybe some css settings, etc) in the databases. The admin interface was going to be a site all it's own. The database settings were going to be hardcoded using CI's database config file. I was just going to have a different database setting for each site.

Using Matchbox, or something similar, I was going to separate the admin of each site out into modules. Each module would represent a site. For instance, I would have http://www.admindomain.com/site_1 to administer site 1 settings and http://www.admindomain.com/site_2 for site_2, and so on.

There were going to be some settings that were going to be overall settings since each of the sites I was planning on doing this to were of the same basic style, so I was going to set a basic non-site related admin section that would loop through each database configured and set whatever settings I changed.

Not sure if that was what you were looking for, or even if it uses best practices, but that was my idea.
#5

[eluser]Twisted1919[/eluser]
It made me an idea though, so let's say the file system is not a problem anymore and i already have some ideas that i want to try .
What about databases ? Would be ok to have a single database for all ?
Something like s1_foo s1_bar s2_foobar s2_barfoo etc . I am thinking that there might be shared content between these , like the users table or the session table , so it might be a good idea to have them in same place. It's not going to be a problem with database server as all of them will use same server .
If it's not ok like this , or you have other thoughts about this , what would you recommend ?
#6

[eluser]theprodigy[/eluser]
Using a single database is fine as long as you keep in mind the amount of storage that will be saved to it. As with anything else, MySQL does have a storage capacity limit that if you go above will result in some funky things happening (data corruption, extremely slow response time, etc). This limit is rather large, and I believe is on a per table limit, so I wouldn't use 1 table for 30 different e-commerce stores that sell different items, but other than that you should be fine.

I used to work for a company that did the one database / multiple site thing due to not wanting to pay for more then 1 database (3rd party hosting and MS Sql Server). As long as you design it right and store a website_id with each record (or something similar), you should be fine.
#7

[eluser]Twisted1919[/eluser]
I took a look here : http://dev.mysql.com/doc/refman/5.0/en/full-table.html
so if i see correct , as far as i know most linux kernels are up to 2.6.x (i compiled a few on 2.6 branch a time ago , and compiling is really a nightmare) so the limit would be on 4TB, a limit that in my opinion could be reached in years.

Another way would be to use separate databases for each site, and in each controller(from admin area) to define which database to be used . As far as i know this can be done pretty easy with CI , right ? But if i do this way i hit a wall on sharing users/sessions/configs between sites , so i think having them in same place is still the best idea in this moment. Anyway,i'll research this further and see what i can find .

Thanks for your time , you really helped me , if you have other thoughts on this let me know.
#8

[eluser]theprodigy[/eluser]
This may get a little hodge-podge to deal with, but you could always use 2 databases per site, 1 for site-specific and 1 for shared content. That way, all the sites would share the 1 for shared content, and each would have it's own site-specific database. You would have to setup the shared content database as the default in order for CI to use it for sessions but other than that, it would just be knowing which database to get what info out of.
#9

[eluser]Twisted1919[/eluser]
I read your solution and i ask myself :
How will i join two tables from two distinct databases ?
Just think at the users as being shared between sites and a simple post table that is used for site B and it is in another database . It will not work like this .
Or maybe i didn't get this right .
There must be an elegant solution out there , but requires some time and tests to find it Smile
#10

[eluser]theprodigy[/eluser]
in mysql, you can use a query that spans multiple databases (with syntax database.table), but I'm not sure about using an actual join. But it never hurts to try ;-)

Try something like:
Code:
$q = "SELECT u.fname, u.lname, b.title, b.content FROM users u JOIN s1_foo.blog b ON b.user_id = u.id";
$results = $this->db->query($q);

I'm not sure if it will work, but like I said, it doesn't hurt to try.




Theme © iAndrew 2016 - Forum software by © MyBB