说明⚠️:其中,如不需要echo模块,将最后一个选项去掉,如需要echo模块,从github上面拉到指定位置
配置 nginx.conf 文件cd /etc/nginx/ cp nginx.conf nginx.conf_bak #cat nginx.conf user duser duser; #Single core worker_processes 2; #Multicore #worker_processes 8; #worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 10240; } http { 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; }#创建更改http,tcp服务目录和权限 mkdir /etc/nginx/http.d mkdir /etc/nginx/stream.d chmod 777 /etc/nginx/http.d chmod 777 /etc/nginx/stream.d修改 nginx 使用权限chmod u+s /usr/sbin/nginx测试#启动nginx nginx #查看nginx服务 ps -ef |grep nginx root 22828 1 0 14:17 ? 00:00:00 nginx: master process nginx duser 23062 22828 0 14:50 ? 00:00:00 nginx: worker process duser 23063 22828 0 14:50 ? 00:00:00 nginx: worker process duser 23064 22828 0 14:50 ? 00:00:00 nginx: worker process duser 23065 22828 0 14:50 ? 00:00:00 nginx: worker process root 23396 23364 0 16:20 pts/2 00:00:00 grep --color=auto nginx #先切到duser账户下 su - duser #自定义一个http服务 cat /etc/nginx/http.d/test.conf server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; } } #平滑重启nginx nginx -t nginx -s reload郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。