Jump to content

can you add a new domain to your hosting account only using php?


dadamssg87

Recommended Posts

and if so how?

 

I've read a few articles and the vast majority talk about subdomains and just have you create an index.php file and use an .htaccess file to look at the domain being called and use the index.php file to display information pertaining to that domain. I want to know how to pragmatically add a domain as if you were going through cPanel's Add Domain process.

 

It wouldn't be as simple as just creating a "newdomain.com" directory in public_html , would it?

Adding a new domain is as simple as adding an new vhost. You can do this programatically using a script (how do you think cPanel does it?), or manually using a text editor.

 

http://httpd.apache.org/docs/2.0/vhosts/examples.html

 

Of course you will also need to add a new DNS entry to point your domain to the servers ip but I assume (because your asking within the Apache board) you already have this covered.

Where it is located is different depending on how Apache has been configured but you can put them wherever you like.

 

Within your main httpd.conf file just place something like:

 

Include /etc/apache2/vhosts.d/*.conf

 

You can then create vhost.conf files within /etc/apache2/vhosts.d/ and they will be included into the main configuration.

 

Using this method however you need to restart Apache every time you add a new vhost. Look in the manual for "mass virtual hosting" for an approach that allows you to add hosts dynamically without the need for restarting.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.