dadamssg87 Posted November 29, 2011 Share Posted November 29, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/252007-can-you-add-a-new-domain-to-your-hosting-account-only-using-php/ Share on other sites More sharing options...
trq Posted November 29, 2011 Share Posted November 29, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252007-can-you-add-a-new-domain-to-your-hosting-account-only-using-php/#findComment-1292109 Share on other sites More sharing options...
dadamssg87 Posted November 29, 2011 Author Share Posted November 29, 2011 i'm a newbie when it comes with messing with apache. Excuse my ignorance, but where is the file with the virtual hosts typically found? And can you rewrite it with php? Quote Link to comment https://forums.phpfreaks.com/topic/252007-can-you-add-a-new-domain-to-your-hosting-account-only-using-php/#findComment-1292266 Share on other sites More sharing options...
trq Posted November 29, 2011 Share Posted November 29, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/252007-can-you-add-a-new-domain-to-your-hosting-account-only-using-php/#findComment-1292379 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.