0

hi I have a raspberry pi and install apache on this. On my raspberry runs raspian and I want to execute linux prompts about my web. For example I have a webapplication run on this apache and I want to shutdown the raspberry by a click on a button "shutdown". (This is only one method for my application). I build webapplications in php or C# with .NET.

Can I do this and what i must know for this?

I want to build a simple Webapplication for other users.

1

1 Answer 1

0

You can use exec(), system() or passthru() function to execute commands.

For example you can shutdown a linux system with:

<?php
    exec("shutdown -h now");
?>

Make sure the apache user has the permission to execute this command.

Sign up to request clarification or add additional context in comments.

2 Comments

But make sure the PHP-Process has enough rights, because only root have the right to restart the machine. Please also note, that this will create critical security issues and should never be reachable over the internet.
That's correct that's why on most webservers these functions are disabled by default. You can make an admin login, correct. But make sure that there is no possibilty to load this site without a login (e.g. SQL Injection)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.