Nginx modify users and groups

Nginx running process needs the support of users and groups, in order to achieve access control to a Web site to read the file.
Nginx nobody default user accounts and group accounts, generally have to be modified.

========================================================

1: When you compile and install designated

[root@localhost conf]# useradd -M -s /sbin/nologin nginx

[root@localhost nginx-1.16.0]# tail -l /etc/passwd;tail -l /etc/group
saned:x:989:983:SANE scanner daemon user:/usr/share/sane:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
roomc:x:1000:1000:roomc:/home/roomc:/bin/bash
named:x:25:25:Named:/var/named:/bin/false
nginx:x:1001:1001::/home/nginx:/sbin/nologin
avahi:x:70:
postdrop:x:90:
postfix:x:89:
stapusr:x:156:
stapsys:x:157:
stapdev:x:158:
tcpdump:x:72:
roomc:x:1000:
named:x:25:

[root@localhost ~]# tar xf nginx-1.16.0.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/nginx-1.16.0/

[root@localhost nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module && make && make install

2: Modify Profile

[root@localhost nginx-1.16.0]# vim /usr/local/nginx/conf/nginx.conf

modify:

Copy the code
user  nginx nginx;               
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    use epoll;
    worker_connections  1024;
}
Copy the code

[root@localhost nginx-1.16.0]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx-1.16.0]# killall -s HUP nginx
nginx: no process found
[root@localhost nginx-1.16.0]# nginx
[root@localhost nginx-1.16.0]# killall -s HUP nginx
[root@localhost nginx-1.16.0]# ps -aux | grep nginx
root 22334 0.0 0.2 151560 5068 pts/1 T 13:33 0:00 vim /usr/local/nginx/conf/nginx.conf
root 25663 0.0 0.0 20692 1392 ? Ss 14:40 0:00 nginx: master process nginx
nginx 25667 0.0 0.0 23208 1488 ? S 14:40 0:00 nginx: worker process
nginx 25668 0.0 0.0 23208 1488 ? S 14:40 0:00 nginx: worker process
root 25678 0.0 0.0 112724 992 pts/1 S+ 14:41 0:00 grep --color=auto nginx

Guess you like

Origin www.cnblogs.com/L1-5551/p/11518478.html
Recommended