PHP 可執行 root 權限 (以 Ubuntu 16.04 為例)

首先修改 /etc/php/7.0/fpm/pool.d/www.conf

[...]
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = root
group = root
[...]

接著修改 /lib/systemd/system/php7.0-fpm.service

ExecStart=/usr/sbin/php-fpm7.0 --nodaemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf

修改為

ExecStart=/usr/sbin/php-fpm7.0 --allow-to-run-as-root --nodaemonize --fpm-config /etc/php/7.0/fpm/php-fpm.conf

重新載入PHP

systemctl daemon-reload
/etc/init.d/php7.0-fpm restart

完成