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 Optimization 2Secretltternginx runs under ordinary users & gt

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

Share

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

Optimization 2:

If you have any questions, you are welcome to correct them.

Modify nginx default users and user groups:

Useradd nginx-s / sbin/nologin-M # login is not allowed

Groupadd nginx

Modifying users and user groups is for nginx's worker process, but master is often root

One is to specify users and groups at compile time:

/ configure-- user=www-- group=www-- prefix=/usr/local/nginx-- with-http_stub_status_module-- with-http_ssl_module-- with-http_gzip_static_module-- with-ipv6-- with-pcre=/opt/soft/pcre-8.12

One is to modify nginx.conf.

Global configuration items:

User www www

Key points:

Let nginx users run under ordinary users:

Useradd zuma

Su-zuma

If the newly created user does not have environment variables:

Resolve:

Su-zuma

Cp / etc/skel/.bash*.

Exit

Su-zuma

If there are still no environment variables, you need to check whether there are other configurations in cat / etc/default/useradd

# useradd defaults file

GROUP=100

HOME=/home

INACTIVE=-1

EXPIRE=

SHELL=/bin/bash

SKEL=/etc/skel

CREATE_MAIL_SPOOL=yes

Delete user

Userdel-r zuma

Su-zuma goes to the user directory of zuma:

Copy the conf folder web directory folder to the / home/zuma directory:

Cp-ap / usr/local/nginx/conf.

Cp-ap / usr/local/nginx/html.

Ln-s / usr/local/nginx/logs logs

Switch to the root user:

Chmod-R 755 / usr/local/nginx/logs

Chown-R. Zuma / usr/local/nginx/logs

Su-zuma

Just start nginx:

/ usr/local/nginx/sbin/nginx-c / home/zuma/conf/nginx.conf

You can view it via ps-ef | grep nginx.

Root 16127 1 0 11:48? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginx

Www 16128 16127 0 11:48? 00:00:01 nginx: worker process

Www 16129 16127 0 11:48? 00:00:00 nginx: worker process

Www 16130 16127 0 11:48? 00:00:01 nginx: worker process

Www 16131 16127 0 11:48? 00:00:01 nginx: worker process

Zuma 20162 1 0 14:25? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginx-c / home/zuma/conf/nginx.conf

Zuma 20163 20162 14 14:25? 00:00:00 nginx: worker process

Zuma 20164 20162 27 14:25? 00:00:00 nginx: worker process

Zuma 20166 16484 1 14:26 pts/1 00:00:00 grep 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