为什么要更改 Nginx 服务的默认用户:就像更改 ssh 的默认 22 端口一样,增加安全性,Nginx 服务的默认用户是 nobody ,我们更改为 nginx 1、添加 nginx 用户 useradd nginx -s /sbin/nologin -M 说明: -s<shell>:指定用户登入后所使用的shell; -M:不要自动建立用户的登入目录 2、更改 Nginx 配置文件 [root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
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;
}
}
}
|
|