注意,本方法仅用于开发环境来解决一些奇怪问题或者方便使用,请勿在生产环境让php-fpm以root身份运行,否则一切后果自负。
- 编辑/etc/php/7.0/fpm/pool.d/www.conf,把user和group修改为root
1234; 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 = rootgroup = root - 编辑/lib/systemd/system/php7.0-fpm.service,在ExecStart的
--nodaemonize前面加上
--allow-to-run-as-root,就像下面这样
1ExecStart=/usr/sbin/php-fpm7.0 --allow-to-run-as-root --nodaemonize... - 执行命令
1systemctl daemon-reload - 重启php-fpm即可
1service php7.0-fpm restart - 最后,可以通过ps命令来查看效果
1ps auwx | grep php
可以看到,php-fpm已经以root身份运行了。