nginx 更改用户组

为什么要更改 Nginx 服务的默认用户:就像更改 ssh 的默认 22 端口一样,增加安全性,Nginx 服务的默认用户是 nobody ,我们更改为 nginx

1) 添加 nginx 用户

useradd -s /sbin/nologin -M nginx

2) 更改 Nginx 配置文件

worker_processes 1;

user nginx nginx; # 指定Nginx服务的用户和用户组

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

server_tokens off;

server {

listen 80;

server_name www.abc.com;

location / {

root html/www;

index index.html index.htm;

}

}

}

3)重新加载nginx 并且 验证是否生效

作者简介: 
陈志珂(头条号:强扭的瓜不好吃)公众号“铅笔学园”运维内容合作作者之一,目前就职于中国最大的安卓应用软件公司,任高级工程师现在公司任php开发工程师,python开发工程师,高级运维工程师。
铅笔学园:IT资源分享|知识分享,做初级程序员的指明灯

原文地址:https://www.cnblogs.com/qianbixueyuan/p/9518738.html