how to do a linux reboot from php file

前端 未结 7 2042
忘掉有多难
忘掉有多难 2020-12-19 10:53

I have a user brftv on my linux system and I have www-data that runs the nginx.

from the terminal I can let my brftv user run

sudo /sbin/reboot


        
相关标签:
7条回答
  • 2020-12-19 11:37

    Try this code

    brftv ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff
     www-data ALL=(brftv) NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff 
    

    then from php

    exec('sudo /sbin/reboot');
    
    0 讨论(0)
提交回复
热议问题