Jump to content

Domains and PHP


Darklink

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

:)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.