Darklink Posted July 16, 2008 Share Posted July 16, 2008 Does anyone know of any exec() commands or other methods that allows PHP to create and/or manage domains on the http server, mainly Apache? If there isn't, then I will have to create an application via C# or something that will do the job and use exec() from there. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 Creating domains in apache can be as simple as dropping a vhost file into the correct location and restarting the server (depending on how you have setup apache's configurations). There's not really any tricks to do it via php, if you know how to create domains manually, simply write a script that follows the same steps. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 ps: When you talk about domains I assume you mean vhosts, apache has nothing at all to do with handling of domain names, thats the job of the DNS server. And again, that process is scriptable. Quote Link to comment Share on other sites More sharing options...
Darklink Posted July 16, 2008 Author Share Posted July 16, 2008 Restart the server!? How come cPanel is able to acomplish this without having to restart the server (or am I deeply mistakened)? I just want to put addon domains for different users automatically via PHP as they submit them and change their nameservers. I'm guessing I would have to create a desktop application and then use exec() to call it to do the job? I'm not looking for any quick tricks in PHP to do this as I know it will mean work and I am willing to spend time into researching and doing this properly along with the rest of the project I am doing. Quote Link to comment Share on other sites More sharing options...
papaface Posted July 16, 2008 Share Posted July 16, 2008 Restart the server!? How come cPanel is able to acomplish this without having to restart the server (or am I deeply mistakened)? I just want to put addon domains for different users automatically via PHP as they submit them and change their nameservers. I'm guessing I would have to create a desktop application and then use exec() to call it to do the job? I'm not looking for any quick tricks in PHP to do this as I know it will mean work and I am willing to spend time into researching and doing this properly along with the rest of the project I am doing. I'm sure cpanel does restart apache when a new domain is added. Quote Link to comment Share on other sites More sharing options...
Darklink Posted July 16, 2008 Author Share Posted July 16, 2008 I thought you would notice when it's being restarted. I take it the virtualization in web hosting sorts the restarting between different users? Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 Apache is congiured via simple text files, desktop app or not, all you need do is manipulate these textr files. PHP is quite capable of doing so. To do it without the need of restarting apache you would use the mod_vhost_alias module which actually makes the task even simpler. Quote Link to comment Share on other sites More sharing options...
Darklink Posted July 16, 2008 Author Share Posted July 16, 2008 Okay, that's given me a more clearer view. I see that the VirtualHost containers are put into the httpd.conf file. Can any of the information in this file be altered and overwritten using .htaccess. If that's the case, I think I know what I can do from here on in. I can just add more VirtualHost containers in the .htaccess automatically using PHP (remembering to set permissions safely and putting extra security measures in obviously). I don't think there would be anything else. I would have to make sure that .htaccess overwrites any configuration settings which I think you can set somewhere. Please correct me if I'm wrong, although I believe I will speak to you soon on MSN. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted July 16, 2008 Share Posted July 16, 2008 If you do a little research on vhost containers.. and ways of storing them outside of the .conf files you dont need to restart apache. I cant remember what its called exactly but there is a method of storing flat files on a domain basis in a directory (for orginizational purposes) that will just read as they are put in.. you would put your vhost directives in the files per domain.. and upon that it would be live, pending theres no errors in the vhost containers. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2008 Share Posted July 16, 2008 If your going to go down the mod_vhost_alias route (which it seems you should) you do not need to define separate vhosts, even if you could, they cannot be defined in a .htaccess file. A .htaccess file only effects the directory it is in. Also, as I hinted at in my first post there are many different ways to setup apache for easy configuration. You don't necessarily need to define vhosts within the main httpd.conf file, there are easier ways. Quote Link to comment 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.