Jump to content

editing httpd.conf with php


brycekmartin

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.

Archived

This topic is now archived and is closed to further replies.

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