You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Lars Nielsen <la...@mit-web.dk> on 2011/02/06 23:05:47 UTC

[users@httpd] PHP to control Apache

Hi,

I am writing a PHP application to control primarily my VirtualHost
configurations in Apache(2.2.9). Can you guide my to any good knowlegde
of 
 1. how to structure the generated configurationfile(s) 
 2. how to reload/restart apache from PHP?

Regards
Lars Nielsen
lars@lfweb.dk - www.lfweb.dk



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Nilesh Govindarajan <ni...@itech7.com>.
You could use incrond to launch a script that would run a script when
a file is modified. the script will test the config & if it is ok
restart apache gracefully.
example:
IN_CREATE,IN_MODIFY /path/to/watch /path/to/script
The above incrontab may be wrong, check with manpage.

On 2/7/11, Lars Nielsen <la...@mit-web.dk> wrote:
> Hi,
>
> I am writing a PHP application to control primarily my VirtualHost
> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
> of
>  1. how to structure the generated configurationfile(s)
>  2. how to reload/restart apache from PHP?
>
> Regards
> Lars Nielsen
> lars@lfweb.dk - www.lfweb.dk
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

-- 
Sent from my mobile device


--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
Cheap and Reliable VPS Hosting: http://j.mp/arHk5e

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Nilesh Govindarajan <ni...@itech7.com>.
You can use incrond to fire a script on create/modification event of a
config file that php would be writing to check the config and restart
apache gracefully if test is succesful

On 2/7/11, Lars Nielsen <la...@mit-web.dk> wrote:
> Hi,
>
> I am writing a PHP application to control primarily my VirtualHost
> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
> of
>  1. how to structure the generated configurationfile(s)
>  2. how to reload/restart apache from PHP?
>
> Regards
> Lars Nielsen
> lars@lfweb.dk - www.lfweb.dk
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

-- 
Sent from my mobile device


--
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/nileshgr
Website: http://www.itech7.com
Cheap and Reliable VPS Hosting: http://j.mp/arHk5e

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Nick Kew <ni...@webthing.com>.
On Sun, 06 Feb 2011 23:05:47 +0100
Lars Nielsen <la...@mit-web.dk> wrote:

> Hi,
> 
> I am writing a PHP application to control primarily my VirtualHost
> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
> of 
>  1. how to structure the generated configurationfile(s) 
>  2. how to reload/restart apache from PHP?

Don't.

Consider using mod_vhost_dbd instead.  It may do all you need, and
it'll be a startingpoint even if it doesn't.


-- 
Nick Kew

Available for work, contract or permanent.
http://www.webthing.com/~nick/cv.html

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Frank Gingras <fr...@gmail.com>.
Lars,

1) http://httpd.apache.org/docs/current/vhosts/examples.html

2) Bad idea, unless you can sudo and call apachectl restart

On 06/02/2011 5:05 PM, Lars Nielsen wrote:
> Hi,
>
> I am writing a PHP application to control primarily my VirtualHost
> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
> of
>   1. how to structure the generated configurationfile(s)
>   2. how to reload/restart apache from PHP?
>
> Regards
> Lars Nielsen
> lars@lfweb.dk - www.lfweb.dk
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See<URL:http://httpd.apache.org/userslist.html>  for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>     "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Lars Nielsen <la...@mit-web.dk>.
ons, 09 02 2011 kl. 14:59 +0100, skrev Fredric Fredricson:
> On 02/09/2011 12:20 PM, Nilesh Govindarajan wrote: 
> > [snip]
> > 
> > The problem with using mod_perl is one needs to know perl to a
> > decent extent or at least db operations in perl. It is a strict
> > requirement. 
> > [snip]
> This, of course, depends on your situation but perl DBI is quite well
> documented and fairly easy to use and Perl, as a language, is not that
> strange and comparable with php (if you exclude the OOP-parts, avoid
> OOP in Perl). As a text processing language, Perl is better than all
> others I have seen and vastly superior to php (not that php is exactly
> bad, perl is just much better). 
> 
> But there is, of course, a learning curve.
> 
> Just saying......
> 
> /Fredric
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

Thank you all for your suggestions,
I will look further into mod_perl and mod_vhost_dbd. I know a little
perl so it might not be that hard!

Thanks.
Regards Lars Nielsen


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Fredric Fredricson <Fr...@bonetmail.com>.
On 02/09/2011 12:20 PM, Nilesh Govindarajan wrote:
> [snip]
>
> The problem with using mod_perl is one needs to know perl to a decent 
> extent or at least db operations in perl. It is a strict requirement.
> [snip]
This, of course, depends on your situation but perl DBI is quite well 
documented and fairly easy to use and Perl, as a language, is not that 
strange and comparable with php (if you exclude the OOP-parts, avoid OOP 
in Perl). As a text processing language, Perl is better than all others 
I have seen and vastly superior to php (not that php is exactly bad, 
perl is just much better).

But there is, of course, a learning curve.

Just saying......

/Fredric

Re: [users@httpd] PHP to control Apache

Posted by Nilesh Govindarajan <ni...@itech7.com>.
On 02/09/2011 01:16 AM, Jorge Schrauwen wrote:
> On Tue, Feb 8, 2011 at 3:01 PM, Matus UHLAR - fantomas
> <uh...@fantomas.sk>  wrote:
>> On 06.02.11 23:05, Lars Nielsen wrote:
>>> I am writing a PHP application to control primarily my VirtualHost
>>> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
>>> of
>>>   1. how to structure the generated configurationfile(s)
>>>   2. how to reload/restart apache from PHP?
>>
>> mod_perl is designed to do such things. It can do much more of course.
> Here is a simple example:
> http://wiki.apache.org/httpd/ApacheVirtualHostMysql
>

The problem with using mod_perl is one needs to know perl to a decent 
extent or at least db operations in perl. It is a strict requirement.
Where as if you use inotify events to reload the config file when it is 
changed, there's no requirement of perl, you can do the automatic config 
modifier in your favorite language.

Another idea (may be bad one) is to use a RewriteMap and generate 
rewrite maps using php (it would be a highly cpu intensive task for 
apache probably, no ideas..never used rewritemap)

-- 
Regards,
Nilesh Govindarajan
Facebook: http://www.facebook.com/nilesh.gr
Twitter: http://twitter.com/_linuxgeek_
Website: http://www.itech7.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Jorge Schrauwen <jo...@gmail.com>.
On Tue, Feb 8, 2011 at 3:01 PM, Matus UHLAR - fantomas
<uh...@fantomas.sk> wrote:
> On 06.02.11 23:05, Lars Nielsen wrote:
>> I am writing a PHP application to control primarily my VirtualHost
>> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
>> of
>>  1. how to structure the generated configurationfile(s)
>>  2. how to reload/restart apache from PHP?
>
> mod_perl is designed to do such things. It can do much more of course.
Here is a simple example:
http://wiki.apache.org/httpd/ApacheVirtualHostMysql

>
> --
> Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
> Warning: I wish NOT to receive e-mail advertising to this address.
> Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
> Nothing is fool-proof to a talented fool.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PHP to control Apache

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 06.02.11 23:05, Lars Nielsen wrote:
> I am writing a PHP application to control primarily my VirtualHost
> configurations in Apache(2.2.9). Can you guide my to any good knowlegde
> of 
>  1. how to structure the generated configurationfile(s) 
>  2. how to reload/restart apache from PHP?

mod_perl is designed to do such things. It can do much more of course.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Nothing is fool-proof to a talented fool. 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org