一般情况下,肯定是不推荐使用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 组件』第一个 Asp.Net 服务器组件:自己的文本框控件

    代码: using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace DemoWebControl ...

  2. 在Java中使用redisTemplate操作缓存

    背景 在最近的项目中,有一个需求是对一个很大的数据库进行查询,数据量大概在几千万条.但同时对查询速度的要求也比较高. 这个数据库之前在没有使用Presto的情况下,使用的是Hive,使用Hive进行一 ...

  3. window环境下使用filezilla server搭建ftp服务器

    前言 在做项目的时候,需要提供ftp服务,开始的时候使用微软自动的iss上的ftp服务,一段时间后发现无法自定义用户,只能使用系统的用户,使用起来很不方便,在权限管理方面也是不太好.所以换用了file ...

  4. man帮助文档打印

    这里不讨论大家都知道的man重定向的一般常用方法(col处理方法)$ man find | col -b > man_fine.txt [跟着我的思路走]假如您像我一样,直接使用如下命令导出fi ...

  5. cache2go源码最后一讲 - examples

    先看一下我们讲到哪里了: cache2go的源码前面我们已经讲完了cacheitem和cachetable的实现,今天cahce和examples会一起讲完~ 1.cache.go源码 ​      ...

  6. ubuntu 修改网卡名称 更改设备网卡名称 修改eno16777736为eth0 ubuntu 15.10网卡名称为eno16777736

    ubuntu linux 进入root用户,管理员模式 编辑这个文件需要管理员模式 在GRUB_CMD_LINUX后面增加图中所示 看到这个地方了没,有提示信息的,想要改变这个文件,记得运行 upda ...

  7. [图解]ARP协议(一)

    一.ARP概述 如果要在TCP/IP协议栈中选择一个"最不安全的协议",那么我会毫不犹豫把票投给ARP协议.我们经常听到的这些术语,包括"网络扫描"." ...

  8. [MySQL] explain中的using where和using index

    1. 查看表中的所有索引 show index from modify_passwd_log;  有两个 一个是id的主键索引 , 一个是email_id的普通索引 2. using index表示 ...

  9. [Go] golang创建目录写文件判断文件

    package main import ( "log" "os" ) func main() { //创建目录 os.Mkdir("test" ...

  10. Python全栈开发之---assert断言

    一.python assert的作用: 根据Python 官方文档解释(https://docs.python.org/3/reference/simple_stmts.html#assert), & ...