Linux使用普通账户管理Nginx的方法
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,创建账户useradd duserNginx编译安装#下载并解压缩nginx包tar zxvf nginx-1.12.2.tar.gzcd nginx-1.12.2#编译安装./configure -
千家信息网最后更新 2025年12月03日Linux使用普通账户管理Nginx的方法
创建账户
useradd duserNginx编译安装
#下载并解压缩nginx包tar zxvf nginx-1.12.2.tar.gzcd nginx-1.12.2#编译安装./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说明⚠️:其中,如不需要echo模块,将最后一个选项去掉,如需要echo模块,从github上面拉到指定位置
配置 nginx.conf 文件
cd /etc/nginx/cp nginx.conf nginx.conf_bak#cat nginx.confuser duser duser;#Single coreworker_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.dmkdir /etc/nginx/stream.dchmod 777 /etc/nginx/http.dchmod 777 /etc/nginx/stream.d修改 nginx 使用权限
chmod u+s /usr/sbin/nginx测试
#启动nginxnginx#查看nginx服务ps -ef |grep nginxroot 22828 1 0 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#先切到duser账户下su - duser#自定义一个http服务cat /etc/nginx/http.d/test.confserver { listen 8080; server_name localhost; location / { root html; index index.html index.htm; }}#平滑重启nginxnginx -tnginx -s reload
服务
账户
权限
模块
编译
平滑
位置
文件
目录
测试
配置
普通
方法
管理
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
有字的网络安全手抄视频
网络安全 企业
我的世界怎么自己创建1.17服务器
法律意见书 数据库
5g网络技术结构
最热门的软件开发
下列哪些不属于网络安全法
软件开发信息安全管控方案
网站本地服务器搭建
合金装备5选择哪个地区服务器
c服务器端开发
代做数据库
网络安全文明管理的重要性
成功软件开发有限公司
vs 打包数据库
金山快盘服务器忙
顾鑫网络技术
万象2004 数据库修改
软件开发 类 项目
近些年网络安全发生的案例
计算机网络技术认证等级
2021网络安全宣传短片厦门
迅购网络技术服务中心
网络安全技术股票
爱迪尔门锁数据库在哪个文件
语音聊天软件开发多年口碑
钻姐网络技术工作室
网络安全证书有效吗
软件开发女生多吗
山西大学刘全明网络安全培训