php使用root用户启动
一般情况下,肯定是不推荐使用root用户启动php的
但是在某些服务器管理想使用WEB的方式来控制操作的话,那么就必须要使用root用户才有权限操作
1、修改配置文件php-fpm.conf的启动用户为root,默认是nobody
我这里的php-fpm配置文件是在这里,
vim /usr/local/php7/etc/php-fpm.d/www.conf
- 17 ; Default Value: none
- 18 ;prefix = /path/to/pools/$pool
- 19
- 20 ; Unix user/group of processes
- 21 ; Note: The user is mandatory. If the group is not set, the default user's group
- 22 ; will be used.
- 23 user = root
- 24 group = www
- 25
- 26 ; The address on which to accept FastCGI requests.
- 27 ; Valid syntaxes are:
- 28 ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
- 29 ; a specific port;
- 30 ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
- 31 ; a specific port;
- 32 ; 'port' - to listen on a TCP socket to all addresses
- 33 ; (IPv6 and IPv4-mapped) on a specific port;
- 34 ; '/path/to/unix/socket' - to listen on a unix socket.
- 35 ; Note: This value is mandatory.
- 36 listen = 0.0.0.0:9000
2、启动PHP
- /usr/local/php7/sbin/php-fpm
启动的时候发现报错,启动不了
- ERROR: [pool www] please specify user and group other than root
- ERROR: FPM initialization failed
默认是不允许root用户启动的
我们可以看下--help
- [root@localhost ~]# /usr/local/php7/sbin/php-fpm --help
- Usage: php-fpm [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F [-O]]
- -c <path>|<file> Look for php.ini file in this directory
- -n No php.ini file will be used
- -d foo[=bar] Define INI entry foo with value 'bar'
- -e Generate extended information for debugger/profiler
- -h This help
- -i PHP information
- -m Show compiled in modules
- -v Version number
- -p, --prefix <dir>
- Specify alternative prefix path to FastCGI process manager (default: /usr/local/php7).
- -g, --pid <file>
- Specify the PID file location.
- -y, --fpm-config <file>
- Specify alternative path to FastCGI process manager config file.
- -t, --test Test FPM configuration and exit
- -D, --daemonize force to run in background, and ignore daemonize option from config file
- -F, --nodaemonize
- force to stay in foreground, and ignore daemonize option from config file
- -O, --force-stderr
- force output to stderr in nodaemonize even if stderr is not a TTY
- -R, --allow-to-run-as-root
- Allow pool to run as root (disabled by default)
- You have new mail in /var/spool/mail/root
这里有个选项,-R, --allow-to-run-as-root,表示允许通过root启动
# /usr/local/php7/sbin/php-fpm -R
启动后验证下
- [root@localhost ~]# ps aux | grep php
- root 2590 0.3 0.4 30352 4296 ? Ss 10:30 0:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
- root 2591 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2592 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2593 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2594 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2595 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2596 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2597 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2598 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2599 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2600 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
- root 2601 0.0 0.2 30352 2604 ? S 10:30 0:00 php-fpm: pool www
这里发现已经使用root用户启动OK。
php使用root用户启动的更多相关文章
- mysql用root用户启动后其他用户无法启动不问题
问题描述:用root账户启动mysql后,在用mysql用户或其他非root账户启动不了mysql问题解决:通过看mysql的err日志,发现 Failed to open log (robert-b ...
- 【出错记录】Tomcat非root用户启动无法拥有权限读写文件
简单记录下,如有必要,将深入补充: 一.非root用户运行Tomcat及原因 由于项目中,为了安全需要,Tomcat将禁止以root形式启动,原因很简单,举个例子,一旦有人恶意将jsp文件透过某个别的 ...
- Linux 解决Deepin深度系统无法在root用户启动Google Chrome浏览器的问题
解决Deepin无法在root用户启动Google Chrome浏览器的问题,步骤如下. 前提:如何用root用户登录系统?编辑 vim /etc/lightdm/lightdm.conf , 找到并 ...
- centos7新增用户并授权root权限、非root用户启动tomcat程序
一.centos7新增用户并授权root权限 cat /etc/redhat-release查看centos版本号 1.禁用root账户登录 vim /etc/ssh/sshd_config 找到这一 ...
- 二进制方式安装docker(非root用户启动docker)
二进制方式安装docker(非root用户启动docker) 一.下载安装包: 地址:https://download.docker.com/linux/static/stable/x86_64/ 这 ...
- Ubuntu配置Tomcat9非root用户启动
unix类系统的root用户具有极大的权利,所以很多时候我们不希望程序以root身份启动,这也就是配置Tomcat以指定身份(非root)启动的初衷,虽然也没人来攻击我的服务器,但本着学习学习的目的, ...
- zzw原创_非root用户启动apache的问题解决(非root用户启动apache的1024以下端口)
场景:普通用户编译的apache,要在该用户下启动1024端口以下的apache端口 1.假设普通用户为sims20,用该用户编译 安装了一个apache,安装路径为/opt/aspire/produ ...
- 使用非root用户启动tomcat
以下操作均为以root用户运行1.添加tomcat用户组 /usr/sbin/groupadd tomcat 2.添加tomcat用户,并限制登录 /usr/sbin/useradd -s /bin/ ...
- Linux下的 mariadb 使用 root 用户启动方式
近日因测试安全产品需要,想调整mariadb的启动用户为root, 经历一番波折后终于成功! 注意:以root身份启动mysql是一项非常危险行为,相当于给了数据库操作用户(数据库管理员或黑客)一个通 ...
随机推荐
- Solr 03 - Solr的模式设计与优化 - 最详细的schema.xml模式文件解读
目录 1 关于schema.xml文件 2 解读schema.xml文件 2.1 field - 配置域 2.2 fieldType - 配置域类型 2.3 copyField - 配置复制域 2.4 ...
- [Python Web]常见的 POST 提交数据的方式
本文参考整理于:https://imququ.com/post/four-ways-to-post-data-in-http.html 简介 这里介绍了,用 POST 方法提交数据时,常见的三种方式: ...
- 【SpringCloud】HystrixCommand的threadPoolKey默认值及线程池初始化
关于threadPoolKey默认值的疑问 使用SpingCloud必然会用到Hystrix做熔断降级,也必然会用到@HystrixCommand注解,@HystrixCommand注解可以配置的除了 ...
- 痞子衡嵌入式:第一本Git命令教程(3)- 变动(status/diff)
今天是Git系列课程第三课,前两课我们都是在做Git仓库准备工作,今天痞子衡要讲的是如何查看Git空间内发生的改动. 本地有了仓库,我们便可以在仓库所在目录下做文件增删改操作,为了确定改动操作的正确性 ...
- SQL——嵌套查询与子查询
前言 sql的嵌套查询可以说是sql语句中比较复杂的一部分,但是掌握好了的话就可以提高查询效率.下面将介绍带in的子查询.带比较运算符的子查询.带any/all的子查询.带exists的子查询以及基于 ...
- Jenkins结合.net平台综合之监听git仓库并自动摘取最新代码编译
前面章节我们讲解了Jenkins结合.net平台工具以及一些第三方工具实现项目自动还原,自动编译,自动测试和自动发布.然而实现自动化还有一个关键的步骤就是监听源码仓库变化然后从仓库拉取最新代码,然后再 ...
- Scala(四) —— 集合
一.List var x = List(1,2,3,4) //x:List[Int] = List(1, 2, 3, 4) var y = List("x","y&quo ...
- 《Web安全深度剖析》
书名 <Web安全深度剖析> 图片 时间 2018-11月 总结 算是我安全的启蒙书 前五章都是工具 看完差不多算个脚本小子 后面的实战感觉很空洞没什么实战
- jsp内置对象的作用范围
内置对象的作用范围是指每个内置对象的某个实例在多长时间和多大的范围中有效,即在什么样的范围内可以有效地访问同一个对象实例. 在javax.servlet.jsp.PageContext的类中定义了4个 ...
- Visual Studio无法调试
一.最近Visual studio调试不起来,运行完报错 二.解决方法 打开 调试>>>>选项>>>>常规>>>对ASP.NET启用 ...