一般情况下,肯定是不推荐使用root用户启动php的

但是在某些服务器管理想使用WEB的方式来控制操作的话,那么就必须要使用root用户才有权限操作

1、修改配置文件php-fpm.conf的启动用户为root,默认是nobody

我这里的php-fpm配置文件是在这里,

vim /usr/local/php7/etc/php-fpm.d/www.conf

  1. 17 ; Default Value: none
  2. 18 ;prefix = /path/to/pools/$pool
  3. 19
  4. 20 ; Unix user/group of processes
  5. 21 ; Note: The user is mandatory. If the group is not set, the default user's group
  6. 22 ;       will be used.
  7. 23 user = root
  8. 24 group = www
  9. 25
  10. 26 ; The address on which to accept FastCGI requests.
  11. 27 ; Valid syntaxes are:
  12. 28 ;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
  13. 29 ;                            a specific port;
  14. 30 ;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
  15. 31 ;                            a specific port;
  16. 32 ;   'port'                 - to listen on a TCP socket to all addresses
  17. 33 ;                            (IPv6 and IPv4-mapped) on a specific port;
  18. 34 ;   '/path/to/unix/socket' - to listen on a unix socket.
  19. 35 ; Note: This value is mandatory.
  20. 36 listen = 0.0.0.0:9000
 

2、启动PHP

  1. /usr/local/php7/sbin/php-fpm

启动的时候发现报错,启动不了

  1. ERROR: [pool www] please specify user and group other than root
  2. ERROR: FPM initialization failed

默认是不允许root用户启动的

我们可以看下--help

  1. [root@localhost ~]# /usr/local/php7/sbin/php-fpm --help
  2. Usage: php-fpm [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F [-O]]
  3. -c <path>|<file> Look for php.ini file in this directory
  4. -n               No php.ini file will be used
  5. -d foo[=bar]     Define INI entry foo with value 'bar'
  6. -e               Generate extended information for debugger/profiler
  7. -h               This help
  8. -i               PHP information
  9. -m               Show compiled in modules
  10. -v               Version number
  11. -p, --prefix <dir>
  12. Specify alternative prefix path to FastCGI process manager (default: /usr/local/php7).
  13. -g, --pid <file>
  14. Specify the PID file location.
  15. -y, --fpm-config <file>
  16. Specify alternative path to FastCGI process manager config file.
  17. -t, --test       Test FPM configuration and exit
  18. -D, --daemonize  force to run in background, and ignore daemonize option from config file
  19. -F, --nodaemonize
  20. force to stay in foreground, and ignore daemonize option from config file
  21. -O, --force-stderr
  22. force output to stderr in nodaemonize even if stderr is not a TTY
  23. -R, --allow-to-run-as-root
  24. Allow pool to run as root (disabled by default)
  25. You have new mail in /var/spool/mail/root

这里有个选项,-R, --allow-to-run-as-root,表示允许通过root启动

# /usr/local/php7/sbin/php-fpm -R

启动后验证下

  1. [root@localhost ~]# ps aux | grep php
  2. root      2590  0.3  0.4  30352  4296 ?        Ss   10:30   0:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
  3. root      2591  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  4. root      2592  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  5. root      2593  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  6. root      2594  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  7. root      2595  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  8. root      2596  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  9. root      2597  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  10. root      2598  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  11. root      2599  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  12. root      2600  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www
  13. root      2601  0.0  0.2  30352  2604 ?        S    10:30   0:00 php-fpm: pool www

这里发现已经使用root用户启动OK。

php使用root用户启动的更多相关文章

  1. mysql用root用户启动后其他用户无法启动不问题

    问题描述:用root账户启动mysql后,在用mysql用户或其他非root账户启动不了mysql问题解决:通过看mysql的err日志,发现 Failed to open log (robert-b ...

  2. 【出错记录】Tomcat非root用户启动无法拥有权限读写文件

    简单记录下,如有必要,将深入补充: 一.非root用户运行Tomcat及原因 由于项目中,为了安全需要,Tomcat将禁止以root形式启动,原因很简单,举个例子,一旦有人恶意将jsp文件透过某个别的 ...

  3. Linux 解决Deepin深度系统无法在root用户启动Google Chrome浏览器的问题

    解决Deepin无法在root用户启动Google Chrome浏览器的问题,步骤如下. 前提:如何用root用户登录系统?编辑 vim /etc/lightdm/lightdm.conf , 找到并 ...

  4. centos7新增用户并授权root权限、非root用户启动tomcat程序

    一.centos7新增用户并授权root权限 cat /etc/redhat-release查看centos版本号 1.禁用root账户登录 vim /etc/ssh/sshd_config 找到这一 ...

  5. 二进制方式安装docker(非root用户启动docker)

    二进制方式安装docker(非root用户启动docker) 一.下载安装包: 地址:https://download.docker.com/linux/static/stable/x86_64/ 这 ...

  6. Ubuntu配置Tomcat9非root用户启动

    unix类系统的root用户具有极大的权利,所以很多时候我们不希望程序以root身份启动,这也就是配置Tomcat以指定身份(非root)启动的初衷,虽然也没人来攻击我的服务器,但本着学习学习的目的, ...

  7. zzw原创_非root用户启动apache的问题解决(非root用户启动apache的1024以下端口)

    场景:普通用户编译的apache,要在该用户下启动1024端口以下的apache端口 1.假设普通用户为sims20,用该用户编译 安装了一个apache,安装路径为/opt/aspire/produ ...

  8. 使用非root用户启动tomcat

    以下操作均为以root用户运行1.添加tomcat用户组 /usr/sbin/groupadd tomcat 2.添加tomcat用户,并限制登录 /usr/sbin/useradd -s /bin/ ...

  9. Linux下的 mariadb 使用 root 用户启动方式

    近日因测试安全产品需要,想调整mariadb的启动用户为root, 经历一番波折后终于成功! 注意:以root身份启动mysql是一项非常危险行为,相当于给了数据库操作用户(数据库管理员或黑客)一个通 ...

随机推荐

  1. asp.net core 系列 2 启动Startup类介绍

    一.Startup类 ASP.NET Core 应用是一个控制台应用,它在其 Program.Main 方法中创建 Web 服务器.其中Main方法是应用的托管入口点,Main 方法调用 WebHos ...

  2. 【斐波那契数列】java探究

    题目描述 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0). n<=39 解析 (1)递归方式 对于公式f(n) = f(n-1) + f(n ...

  3. 程序员过关斩将--面试官再问你Http请求过程,怼回去!

    菜菜哥,X总在产品部瞎指挥,作为程序媛的我都快撑不住了 不光你撑不住了,大家都要撑不住了,外行人指导内行人,呵呵 前天我偷偷的去面试了,结果挂了 出去转转其实是好事,面试官问你什么了? 他让我描述一个 ...

  4. 从SQL Server CloudDBA 看云数据库智能化

    最近阿里云数据库SQL Server在控制台推出了CloudDBA服务,重点解决数据库性能优化领域问题,帮助客户更好的使用好RDS数据库,这是继MySQL之后第二个关系型数据库提供类似的服务.   数 ...

  5. 全图化引擎(AI·OS)中的编译技术

    全图化引擎又称算子执行引擎,它的介绍可以参考从HA3到AI OS -- 全图化引擎破茧之路.本文从算子化的视角介绍了编译技术在全图化引擎中的运用.主要内容有: 1. 通过脚本语言扩展通用算子上的用户订 ...

  6. Jenkins持续集成01—Jenkins服务搭建和部署

    一.介绍Jenkins 1.Jenkins概念 Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Je ...

  7. [一]FileDescriptor文件描述符 标准输入输出错误 文件描述符

    文件描述符   当应用程序请求打开或者操作文件时,操作系统为应用程序设置一张文件列表,具体的实现形式此处不深入说明 操作系统会提供给你一个非负整数,作为一个索引号,它的作用就像地址或者说指针或者说偏移 ...

  8. 使用LR编写下载类脚本

    如何下载并保存文件到本地,实现文件下载的脚本制作.以下是本人测试某系统总结整理的脚本,仅供参考. #include "lrs.h" Action() { // 示例一: //第一种 ...

  9. Error - The debugger's worker process (msvsmon.exe) unexpectedly exited.

    Error - The debugger's worker process (msvsmon.exe) unexpectedly exited. 解决方法:Tools->Options-> ...

  10. aspx 页面中 js 引用与页面后台的数据交互 --【 后台调用 js 】

    js 中调用后台方法   一.用Response.Write方法 Response.Write("<script type='text/javascript'>alert(&qu ...