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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.