切换 openresty 和 nginx 时遇到的问题

我正在尝试使用 exec 切换 php 中的 nginxopenresty

我使用以下命令切换到 openresty:exec('/bin/systemctl stop nginx ; /usr/local/openresty/nginx/sbin/nginx -p /usr/local/openresty/nginx');

我使用以下命令切换到 nginx:exec('/usr/local/openresty/nginx/sbin/nginx -s stop ; /bin/systemctl start nginx');

这两个命令都可以在 ssh 中正常工作,但是从 php 中我无法启动 nginx。执行这个命令 /bin/systemctl start nginx 似乎没有执行。我曾尝试从 .sh 文件中执行该代码,但没有成功。

点赞
用户6482676
用户6482676

尝试使用

exec('/usr/local/openresty/nginx/sbin/nginx -s stop && /bin/systemctl start nginx');
2019-02-03 05:15:37
用户2452680
用户2452680

我用以下命令切换到 openresty 并使其工作:

shell_exec('/bin/systemctl stop nginx; /usr/local/openresty/nginx/sbin/nginx -p /usr/local/openresty/nginx');

同时,用以下命令切换回 nginx:

shell_exec('/usr/local/openresty/nginx/sbin/nginx -s stop; /bin/systemctl restart nginx');
2019-02-09 23:06:28