Jump to content

Recommended Posts

I'm working on a project and I want to automate the process of adding an <virtual host></virtual host> entry into httpd.conf.  What I was thinking is that I could find the last instance of </virtual host> in the file and then add my new record after that.

 

The problem, is how do I position to the last instance of </virtual host> in the file?  Once I have the pointer set its easy to write to the file.

 

Any help will be appreciated.

 

Thanks

Bryce

Link to comment
https://forums.phpfreaks.com/topic/204246-editing-httpdconf-with-php/
Share on other sites

There is an Include directive available within the Apache config files. This directive also allows wildcards. So, you could use something like....

 

Include /var/www/vhosts/*.conf

 

Within your httpd.conf file. This would make it much easier as you could now use php to simply create new .conf files (one for each vhost) within /var/www/vhosts

 

This is similar to how my CMS used to work.

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.