Spencer
Spencer

Reputation: 597

PHP Manage/Add Virtualhost

Is there a free PHP script that allows you to easily add a virtualhost?

I need to do this, because I'll be opening a free forum host, and want to allow users to use their own domain, aside from a free subdomain.

Upvotes: 2

Views: 856

Answers (3)

TyrantBuilt
TyrantBuilt

Reputation: 11

Easy way is to wildcard all domains to a set directory then there use mod rewrite to map the specific domains to specific directories or in the case of say a MU wordpress install you can use the domain to map to a user account.

you can edit the .htaccess file on the fly without restarting apache.

Upvotes: 1

s_p
s_p

Reputation: 4693

couldnt php create a vhost file which is included in the main vhost handle this? using cron to determine weather there has been updates to the attached vhost you could reload apache

Upvotes: 0

Alister Bulman
Alister Bulman

Reputation: 35149

Restarting the server whenever you add a new domain to it could be problematic. If there was ever a problem writing the file, you lose all the sites, and if there is data cached (I'm thinking mainly about APC), you also lose the usefulness of the cache.

Having the default virtual host handle the new domains, and then having the PHP code acting according to $_SERVER['HTTP_HOST'] would be a more robust solution.

Upvotes: 3

Related Questions