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

Linux's method of using ordinary accounts to manage Nginx

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Create account useradd duserNginx compilation installation # download and extract the nginx package tar zxvf nginx-1.12.2.tar.gzcd nginx-1.12.2# compilation installation. / configure-prefix=/etc/nginx-sbin-path=/usr/sbin/nginx-modules-path=/usr/lib64/nginx/modules-conf-path=/etc/nginx/nginx.conf-error-log-path=/var/log/nginx/error.log-http-log-path=/var/log/ Nginx/access.log-pid-path=/var/run/nginx.pid-lock-path=/var/run/nginx.lock-http-client-body-temp-path=/var/cache/nginx/client_temp-http-proxy-temp-path=/var/cache/nginx/proxy_temp-http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp-http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp-http-scgi-temp-path=/var / cache/nginx/scgi_temp-user=nginx-group=nginx-with-compat-with-file-aio-with-threads-with-http_addition_module-with-http_auth_request_module-with-http_dav_module-with-http_flv_module-with-http_gunzip_module-with-http_gzip_static_module-with-http_mp4_module-with-http_random_index_module-with-http_realip_module- With-http_secure_link_module-with-http_slice_module-- with-http_ssl_module-- with-http_stub_status_module-- with-http_sub_module-- with-http_v2_module-- with-mail-- with-mail_ssl_module-- with-stream-- with-stream_realip_module-- with-stream_ssl_module-- with-stream_ssl_preread_module-- with-cc-opt='-O2-g-pipe-Wall-Wp -D_FORTIFY_SOURCE=2-fexceptions-fstack-protector-strong-- param=ssp-buffer-size=4-grecord-gcc-switches-M64-mtune=generic-fPIC'-with-ld-opt='-Wl,-z,relro-Wl,-z,now-pie'-- add-module=/tmp/echo-nginx-modulemakemake install

Description ⚠️: if the echo module is not needed, remove the last option. If you need the echo module, pull it from the github to the specified location.

Configure the nginx.conf file cd / etc/nginx/cp nginx.conf nginx.conf_bak#cat nginx.confuser duser duser;#Single coreworker_processes 2: multiplayer workerships / 8 include workerscomputers: 00000001 00000010 00000100 00001000 000000 100000 01000000 1000000000 log / var/log/nginx/error.log warn;pid / var/run/nginx.pid;events {include / etc/nginx/mime.types; default_type application/octet-stream;} Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"$http_host"'$request_time $upstream_response_time $pipe-$upstream_addr'; log_format post_format $request_body Access_log / var/log/nginx/access.log main; sendfile on; # tcp_nopush on; keepalive_timeout 120; proxy_connect_timeout 600; proxy_send_timeout 600s; proxy_read_timeout 600s; # gzip on; include / etc/nginx/http.d/*.conf } stream {log_format proxy'$remote_addr [$time_local]'$protocol $status $bytes_sent $bytes_received''$session_time "$upstream_addr"'"$upstream_bytes_sent"$upstream_bytes_received"$upstream_connect_time"; access_log / var/log/nginx/stream.access.log proxy Include / etc/nginx/stream.d/*.conf } # create and change http Tcp service directory and permissions mkdir / etc/nginx/http.dmkdir / etc/nginx/stream.dchmod 777 / etc/nginx/http.dchmod 777 / etc/nginx/stream.d modify nginx usage rights chmod Utility / usr/sbin/nginx Test # launch nginxnginx# to view the nginx service ps-ef | grep nginxroot 22828 10 14:17? 00:00:00 nginx: master process nginxduser 23062 22828 0 14:50? 00:00:00 nginx: worker Processduser 23063 22828 0 14:50? 00:00:00 nginx: worker processduser 23064 22828 0 14:50? 00:00:00 nginx: worker processduser 23065 22828 0 14:50? 00:00:00 nginx: worker processroot 23396 23364 0 16:20 pts/2 00:00:00 grep-color=auto nginx# cut to duser account su-duser# Custom a http service cat / etc/nginx/http.d/test.confserver {listen 8080 Server_name localhost; location / {root html; index index.html index.htm;}} # smoothly restart nginxnginx-tnginx-s reload

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