Answer the question
In order to leave comments, you need to log in
Does php work on bash?
Good day. I wanted to ask knowledgeable people. Let's say I have several users on my small server. Let it be game servers. Let's say there is a web server on Apache with a couple of pages. There are several bash scripts (copying, stopping, starting servers). So. There is an idea to enter into a page or create pages in php, for example, in the form of buttons, so that these buttons run one or another script on the server. Is it even possible? So that php "influences" scripts somehow?
Answer the question
In order to leave comments, you need to log in
<?php
if ($_GET['run']) {
# This code will run if ?run=true is set.
exec("/path/to/name.sh");
}
?>
<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<a href="?run=true">Click Me!</a>
Perhaps via exec, not very safe.
As for the rights - exec is executed from the rights of the user from which Apache is running (or a specific entry, in the case of mpm-itk). It can be solved through sudo, it can be done through a separate entry with the desired user in mpm-itk.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question