how to do a linux reboot from php file

前端 未结 7 2050
忘掉有多难
忘掉有多难 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');
    

提交回复
热议问题