turn off apache
Moderator: General Moderators
-
ratamaster
- Forum Newbie
- Posts: 23
- Joined: Fri Oct 15, 2004 6:36 am
turn off apache
HI
Is there a way to turn off apache with php?
Is there a way to turn off apache with php?
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: turn off apache
Maybe try something like this? 
...though seriously I'm not sure. 
Code: Select all
<?php
while(1) {
echo "weeeeeeeeeeeeeeeeee!\n";
}
?>- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: turn off apache
Can I ask why you would want to do that?
For the record, you can. You would need to somehow su to root then call a shell command to do it. It is a lot easier to do this at the command line since doing it by way of the web server means losing PHP as soon as Apache stops.
For the record, you can. You would need to somehow su to root then call a shell command to do it. It is a lot easier to do this at the command line since doing it by way of the web server means losing PHP as soon as Apache stops.
-
ratamaster
- Forum Newbie
- Posts: 23
- Joined: Fri Oct 15, 2004 6:36 am
Re: turn off apache
Actually I don't want this
the customer wants it.
This is for a intranet frontend.
We need
- Restart
- Update
- Shutdown
Could you give me an example pls?
This is for a intranet frontend.
We need
- Restart
- Update
- Shutdown
Could you give me an example pls?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: turn off apache
Create a shell script that does all that for you. Then call the shell script. Be prepared for unexpected results with this though.
-
ratamaster
- Forum Newbie
- Posts: 23
- Joined: Fri Oct 15, 2004 6:36 am
Re: turn off apache
Create a shell script that does all that for you. Then call the shell script. Be prepared for unexpected results with this though.
Could you write an example pls! I have no idea how achieve this, should I use the function exec()?
Could you write an example pls! I have no idea how achieve this, should I use the function exec()?
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: turn off apache
You can use exec or you can backtick your command. Do you have knowledge of how to control apache from the command line?
-
ratamaster
- Forum Newbie
- Posts: 23
- Joined: Fri Oct 15, 2004 6:36 am
Re: turn off apache
how could it be? something like this into a php file:
<?php
exec('apachectl -k stop');
?>
or
exec('apachectl -k stop');
exec('apachectl -k graceful');
<?php
exec('apachectl -k stop');
?>
or
exec('apachectl -k stop');
exec('apachectl -k graceful');
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: turn off apache
Yes, something like that (graceful is probably the best approach).
Now go try it and see if it works.
Now go try it and see if it works.