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是一项非常危险行为,相当于给了数据库操作用户(数据库管理员或黑客)一个通 ...
随机推荐
- 『Asp.Net 组件』第一个 Asp.Net 服务器组件:自己的文本框控件
代码: using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace DemoWebControl ...
- 在Java中使用redisTemplate操作缓存
背景 在最近的项目中,有一个需求是对一个很大的数据库进行查询,数据量大概在几千万条.但同时对查询速度的要求也比较高. 这个数据库之前在没有使用Presto的情况下,使用的是Hive,使用Hive进行一 ...
- window环境下使用filezilla server搭建ftp服务器
前言 在做项目的时候,需要提供ftp服务,开始的时候使用微软自动的iss上的ftp服务,一段时间后发现无法自定义用户,只能使用系统的用户,使用起来很不方便,在权限管理方面也是不太好.所以换用了file ...
- man帮助文档打印
这里不讨论大家都知道的man重定向的一般常用方法(col处理方法)$ man find | col -b > man_fine.txt [跟着我的思路走]假如您像我一样,直接使用如下命令导出fi ...
- cache2go源码最后一讲 - examples
先看一下我们讲到哪里了: cache2go的源码前面我们已经讲完了cacheitem和cachetable的实现,今天cahce和examples会一起讲完~ 1.cache.go源码 ...
- ubuntu 修改网卡名称 更改设备网卡名称 修改eno16777736为eth0 ubuntu 15.10网卡名称为eno16777736
ubuntu linux 进入root用户,管理员模式 编辑这个文件需要管理员模式 在GRUB_CMD_LINUX后面增加图中所示 看到这个地方了没,有提示信息的,想要改变这个文件,记得运行 upda ...
- [图解]ARP协议(一)
一.ARP概述 如果要在TCP/IP协议栈中选择一个"最不安全的协议",那么我会毫不犹豫把票投给ARP协议.我们经常听到的这些术语,包括"网络扫描"." ...
- [MySQL] explain中的using where和using index
1. 查看表中的所有索引 show index from modify_passwd_log; 有两个 一个是id的主键索引 , 一个是email_id的普通索引 2. using index表示 ...
- [Go] golang创建目录写文件判断文件
package main import ( "log" "os" ) func main() { //创建目录 os.Mkdir("test" ...
- Python全栈开发之---assert断言
一.python assert的作用: 根据Python 官方文档解释(https://docs.python.org/3/reference/simple_stmts.html#assert), & ...