I am a newbie here, I am having a bash script which can be executed through terminal with sudo permission only. I want to run it from PHP with proper security. I dont know where to start to accomplish this considering security in mind. Should I create a additional user or what Will be the better way to achieve this. I got a reference with Running command-line application from PHP as specific user, but I am using Nginx and the mentioned solution does not work for me.
Asked
Active
Viewed 58 times
1 Answers
0
NGINX is a web server and not the interpreter. It is not very relevant.
In the standard NGINX + PHP-FPM setup, you should have a separate system user for your website anyway. So you don't need to create an extra user just for that command.
Simply ensure that this "website user" is able to sudo
run your script, without being prompted for their password. This is achieved by visudo
.
example ALL=/path/to/your/script
Where example
is the PHP-FPM pool user, aka, the "website user" and the owner of the website's files.

Danila Vershinin
- 8,725
- 2
- 29
- 35