>Can we reboot a linux server using a php page? Under certain conditions, probably.
You could run Apache as root, but that's stupid. Instead, you'd need a sudo script that does shutdown without requiring a user to actually *BE* root. That script should almost-for-sure be owned and executable by a single special user named 'shutdown' or something like that. If you make it nobody executable, anybody who can log in can shut down your server, and that's probably not acceptable. But might be, depending on extreme circumstances. Next, you'd want to add a different mime-type and extension to Apache and run PHP as a CGI process owned by the user 'shutdown' via suExec (or move to Apache 2.0 [not recommended] and its ability to run PHP as a specific user on a directory-by-directory basis). You can find docs on suExec at http://apache.org/ Then, create your PHP script owned by that 'shutdown' user with something not unlike: <?php exec('shutdown -r now', $results, $error); echo implode("<BR>\n", $results; if ($error){ echo "OS Error: $error. Usually path/permissions, but read 'man errno' to be sure.<BR>\n"; } ?> I would put this in a separate directory (password-protected, of course) and add some code at the top of the PHP above to be sure it was accessed only via SSL (search the archives). Also save it with a different extension than just plain old .php, such as .phpshutdown And, of course, you'll need to use that extension and a different mime-type in your AddType line in httpd.conf for the suExec CGI PHP, as well as the Action directive in httpd.conf to use the suExec you set up. Note that this will not interfere in the least with your existing PHP Module already running -- As far as Apache is concerned, they have nothing to do with each other. >And is it recommended? If you have to ask, probably not :-) If you understand HTTPS and choose a good username/password and are careful about not writing it down, and so on and so on, I suppose it would be okay... If you don't really understand what I typed above, you are doing something very very risky, and you probably shouldn't do it at all. Hire somebody who knows what they are doing to do it instead. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php