dongyue8640 2016-09-15 15:25
浏览 252

通过php重启nginx不起作用

I'm trying to restart nginx from php

The problem is when I type the code from my command line everything work fine but from my php i got this as an output

* Restarting nginx nginx ...fail!

My php code is

 echo   shell_exec ("service nginx restart");

file permission 7777

nginx error log

2016/09/15 15:17:13 [emerg] 2872#0: open() "/run/nginx.pid" failed (13: Permission denied)
2016/09/15 15:30:30 [warn] 2997#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2016/09/15 15:30:30 [emerg] 2997#0: open() "/run/nginx.pid" failed (13: Permission denied)
  • 写回答

1条回答 默认 最新

  • dsigg21445 2016-09-15 17:22
    关注

    I solved the problem by adding this command inside sudo users

    what i did is

    1-visudo
    

    2-go to the last line and add this

     www-data  ALL = NOPASSWD: /etc/init.d/nginx reload
    

    and the problem is fixed

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度