【转】更改 Nginx 服务的默认用户
作者: 孔雀东南飞
原文出处:https://www.cnblogs.com/pzk7788/p/6922787.html
为什么要更改 Nginx 服务的默认用户:就像更改 ssh 的默认 22 端口一样,增加安全性,Nginx 服务的默认用户是 nobody ,我们更改为 nginx
1、添加 nginx 用户
useradd nginx -s /sbin/nologin -M
2、更改 Nginx 配置文件
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.confworker_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
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
4、验证是否生效 [root@localhost ~]# ps aux | grep nginx
root 8901 0.0 0.1 45036 1784 ? Ss 13:54 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 8909 0.0 0.1 45460 1828 ? S 13:59 0:00 nginx: worker process # Nginx进程的所属用户为nginx
«上一篇:CentOS 查询yum安装的软件及路径
Linux命令拾遗:下一篇»
还没有任何评论,你来说两句吧