php透過sudo具有root的權限 (Ubuntu)
修改 /etc/sudoers 檔案
在下面加入
www-data ALL=(ALL) NOPASSWD:ALL
www-data 是Ubuntu的Apache的預設使用者
NOPASSWD:ALL 表示下sudo執行任何指令都不需要再輸入密碼
這樣php就可以使用
system 或 shell_exec 等指令控制 Linux 主機了。
例如:
system("sudo init 0");
就可以讓 Linux 主機關機。
Today's Visitors: 0 Total Visitors: 72
Personal Category: Linux
Topic: feeling / personal / murmur
Previous in This Category: NFS Server (Ubuntu版) Next in This Category: ubuntu 10.10後 bonding
Previous in This Category: NFS Server (Ubuntu版) Next in This Category: ubuntu 10.10後 bonding
學習筆記!!(1)

Sealed (Sep 5)
No one can comment