修改Nginx用户和组!
Nginx 运行时进程需要有用户与组的支持,以实现对网站文件读取时进行访问控制。
Nginx 默认使用 nobody 用户账号与组账号,一般也要进行修改。
========================================================
1:编译安装时指定
[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:
【修改Nginx用户和组!】[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:修改配置文件
[root@localhost nginx-1.16.0]# vim /usr/local/nginx/conf/nginx.conf
修改:
usernginx nginx; worker_processes2; #error_loglogs/error.log; #error_loglogs/error.lognotice; #error_loglogs/error.loginfo; #pidlogs/nginx.pid; events { use epoll; worker_connections1024; }
[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
转载于:https://www.cnblogs.com/cxm123123form/p/11511856.html
推荐阅读
- 编写字典程序
- 精细化的思考
- 用科学的思维做最好的自己
- 监控nginx
- cocosbcx白皮书解读(一)|cocosbcx白皮书解读(一)| 区块链如何统一开发者、发行商、用户之间的利益
- java|java b2b2c shop 多用户商城系统源码- config 修改配置
- iOS富文本为html时,修改默认字体颜色
- react-navigation|react-navigation 动态修改 tabBar 样式
- 借呗用户被银行拉黑贷不到款(马云(怪我咯?))
- 8、Flask构建弹幕微电影网站-搭建后台页面-密码修改、主页控制面板