-1

I am building office management software on a LAMP server on a SAAS model. My clients typically have 5-10 thousand customers they are tracking with all of their contact, invoicing, appointment information. I want to keep each clients information in a separate Database. This I believe will in the long run improve performance, ensure better separation of data, and be cleaner.

So what I want to have happen is for company1.mysite.com and company2.mysite.com to both point to the same site, but pass on their subdomain as a parameter to php.

How do I use apache and vhosts to pass on the subdomain as a parameter to php while still using the same application for all subdomains.

Jared Green
  • 71
  • 1
  • 6
  • Database architecture is probably way off topic here, IMHO. – SpacemanSpiff Nov 27 '12 at 05:13
  • Well, more so I'm interested in structuring it from the Apache perspective with subdomains. Like company1.mysite.com connects to company1 database while company2.mysite.com connects to company2 database. That's what I think I want, but am open to suggestions if there is a better way. – Jared Green Nov 27 '12 at 05:22
  • Apache knows nothing about the database your application uses. You'll need to handle that in php. – EEAA Nov 27 '12 at 06:17
  • I just edited the question, I didn't explain what I wanted very well – Jared Green Nov 27 '12 at 14:08

1 Answers1

2

This probably belongs on Stack Overflow, but...

In your PHP code, you check the value of $_SERVER['HTTP_HOST'] to determine the hostname which was used.

In your Apache <VirtualHost> use a wildcard ServerAlias to serve all possible subdomains of the domain name from the same virtual host.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940