Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx optimized change user

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1.1 change the nginx default user

Change the default user of nginx. Generally, the default user is nobody after nginx is started.

[root@web01 conf] # grep'# user' nginx.conf.default

# user nobody

[root@web01 conf] #

In order to prevent * * guessing the user of this web service, we need to change it to a special name, such as nginx or CC with special points, but this user must exist in advance in the system and use nginx to make a special description.

1.1.1 nginx service creates new users

Create a new user action for nginx as follows

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

[root@web01 ~] # id nginx

Uid=1310 (nginx) gid=1310 (nginx) groups=1310 (nginx)

[root@web01 ~] #

1.1.2 configure the nginx service to use the newly created nginx user

There are two default users for changing nginx

The first is to change the profile parameters directly

[root@web01 conf] # grep'# user' nginx.conf.default

# user nginx

The second method is to specify the user and group commands to compile when compiling nginx software directly:

. / configure-user=nginx-group=nginx...

1.2 check the effect of changing the user

After reloading the configuration, check the corresponding user of the nginx service process, as follows

[root@web01 ~] # ps-ef | grep nginx

Root 1409 1 0 21:38? 00:00:00 nginx: master process / application/nginx/sbin/nginx

Nginx 1803 1409 0 23:58? 00:00:00 nginx: worker process

Root 1808 1786 0 23:59 pts/0 00:00:00 grep nginx

[root@web01 ~] # ps-ef | grep nginx | grep-v grep

The main process becomes root worker press, the user becomes nginx.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report