Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting and Stoping Apache from a Webpage

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello everyone I am trying to use PHP and JavaScript to create a wonderful Web Hosting company. That I wish to be 99% automated. (There will always be some work for us.) Right now I am having trouble trying to make a popup window that will stop Apache. Then Restart it. Can anyone help me with this.
Or am I getting ahead of my self and doing this all wrong.
 
Use the php system or exec function. I would have the popup come from another instance of Apache (on another port), otherwise you risk cutting yourself off before you've finished your restart!

something like:
Code:
exec("C:\\apache\\Apache -k restart");

Another option would be if you have it installed as a services, but his would require 2 different execs:
Code:
exec("C:\\winnt\\system32\\net stop Apache");
exec("C:\\winnt\\system32\\net start Apache");[code]

Again, this is a huge risk! Be careful! -gerrygerry
 Go To [URL unfurl="true"]http://quickfreewebsite.com![/URL]
 
Hmm, this is something I need as well, however I need it for a localhost Apache server and I'd like to be able to stop it using either javascript or perl
 
it works the same, even if it is a localhost.

there's no way to do it with client-side javascript... maybe with perl... i dunno - ask in the perl forum. php is the easiest way to do it though.

good luck! -gerrygerry
Go To
 
Obviously, if you want to stop Apache from a webpage, you will need a separate HTTP server to enable you to start it up again from a webpage.

The Webmin system ( has been doing this for years, simply by using a Perl daemon that serves secure HTTPS protocol on a separate port. Actually, webmin is quite an impressive web-based admin toolkit for Unix systems in general, but its main function is to administrate almost all aspects of Apache.

I personally would never trust something like Webmin for complete Apache administration, but it is nice to be able to start and stop Apache, and even reboot the server from a remote (secure) webpage.

Webmin is only available for Unix. If you are running Apache/PHP in windows, or if you don't want to use Webmin, you could consider running a separate instance of a webserver on another port. Apache allows for this, as well as many other "lightweight" webservers.

Note: never ever do this without SSL, if you want your system to be reasonably secure. -------------------------------------------

"Now, this might cause some discomfort..."
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top