JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

nginx 更改用户组

wys521 2024-09-14 13:45:34 精选教程 30 ℃ 0 评论

为什么要更改 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 并且 验证是否生效

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表