F
F
fred55rus2017-08-14 17:43:27
linux
fred55rus, 2017-08-14 17:43:27

How to restart nginx via php on debian?

I have a command in php script that should reload nginx config:

var_dump(exec("/usr/local/nginx/sbin/nginx -s reload 2>&1"));

however, after running the script in the browser, the config does not reload, and I get this message on the screen:
string(85) "2017/08/14 08:32:36 [alert] 7919#0: kill(7676, 1) failed (1: Operation not permitted)"

What is the problem and how to solve it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
fred55rus, 2017-08-15
@fred55rus

All right, I got it.
My script was run under a user who has no rights (www-data).
In order for the script to run, I installed the sudo module and added the line in its config (visudo): www-data ALL=NOPASSWD: ALL
Before the command itself, I now attribute sudo -Sand it works.

K
Konstantin Malyarov, 2017-08-14
@Konstantin18ko

Translation: operation is not allowed.
Maybe not enough rights?

M
Maksim Fedorov, 2017-08-14
@Maksclub

are you sure it's not www-data that runs the script?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question