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是一项非常危险行为,相当于给了数据库操作用户(数据库管理员或黑客)一个通 ...
随机推荐
- C++版 - UVa1585 Score - 题解
C++版 - UVa1585 Score - 题解 <算法竞赛入门经典(第二版)> 习题3-1 得分(ACM/ICPC Seoul 2005,UVa1585) 问题描述: 给出一个由O和X ...
- .NET之消息推送(SignalR即时通讯实现)
前言 ASP .NET SignalR 是一个ASP .NET 下的类库,可以在ASP .NET 的Web项目中实现实时通信.什么是实时通信的Web呢?就是让客户端(Web页面)和服务器端可以互相通知 ...
- C#7.0新特性
前言 微软昨天发布了新的VS 2017 ..随之而来的还有很多很多东西... .NET新版本 ASP.NET新版本...等等..太多..实在没消化.. 分享一下其实2016年12月就已经公布了的C#7 ...
- leetcode — scramble-string
import java.util.Arrays; /** * Source : https://oj.leetcode.com/problems/scramble-string/ * * Given ...
- [React] 从零开始的react
组件 1. 无状态组件 在React中,组件的名字必须用大写字母开头,而包含该组件定义的文件名也应该是大写字母(便于区分,也可以不是). 无状态组件是纯展示组件,仅仅只是用于数据的展示,只根据传入的p ...
- shell32.dll 控制网络
//禁用 SetNetworkAdapter(False) //启用 SetNetworkAdapter(True) //添加引用system32/shell32.dll private static ...
- js 数组插入和删除处理
function insertArray(arr, val, compare, maxLen) { //返回位置 const index = arr.findIndex(compare) if (in ...
- prufer序列笔记
prufer序列 度娘的定义 Prufer数列是无根树的一种数列.在组合数学中,Prufer数列由有一个对于顶点标过号的树转化来的数列,点数为n的树转化来的Prufer数列长度为n-2. 对于一棵确定 ...
- 环境配置(pycharm+virtualenv+git+github等)
本文转载自https://blog.csdn.net/xiaogeldx/article/details/87315081 铺垫 数据表示方式 - 计算机使用二进制作为自己的机器语言也就是数据的表示方 ...
- 下载Dynamics 365 Customer Engagement 工具
微软动态CRM专家罗勇 ,回复312或者20190311可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 从Dynamics ...