我的知识记录

虚拟主机Nginx高并发_修复实操

中资源虚拟主机做Nginx高并发,宝塔面板用户在面板"网站"里改配置,面板自动检测语法。手动改 /www/server/panel/vhost/nginx/ 下的配置后,必须nginx -t通过再reload,否则整站挂。

Apache配置结构:主配置httpd.conf → Include conf.d/*.conf → 虚拟主机VirtualHost → .htaccess(目录级覆盖)。.htaccess需要AllowOverride All才生效,mod_rewrite模块要开启。Apache配置改完systemctl reload httpd,.htaccess改完立即生效不需要重启。

参考(Nginx配置与排查): ``` # 语法检测与重载 nginx -t nginx -s reload # 或 systemctl reload nginx

# 服务状态 systemctl status nginx systemctl restart nginx

# 错误日志 tail -50 /var/log/nginx/error.log tail -100 /www/wwwlogs/错误日志.log

# 端口监听 netstat -tlnp | grep nginx ss -tlnp | grep :80

# Nginx站点配置示例 server { listen 80; server_name 域名; root /www/wwwroot/域名; index index.html index.php;

# 伪静态 location / { try_files $uri $uri/ /index.php?$query_string; }

# PHP location ~ .php$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; }

# 上传大小 client_max_body_size 100m;

# 禁止敏感文件 location ~* .(sql|bak|log|sh)$ { deny all; } } ```

安全配置:server_tokens off隐藏版本号、add_header X-Frame-Options SAMEORIGIN防点击劫持、add_header X-Content-Type-Options nosniff、SSL用TLS1.2+、禁止敏感文件访问(location ~* .(sql|bak|log)$ { deny all; })、后台路径IP白名单、限流limit_req。

Nginx与Apache区别:Nginx事件驱动异步非阻塞,高并发性能好,配置简洁,不支持 .htaccess;Apache进程/线程驱动,稳定,支持 .htaccess和丰富模块,高并发内存占用大。静态资源和高并发选Nginx,需要 .htaccess和复杂模块选Apache,也可以Nginx反代Apache。

虚拟主机Nginx高并发_修复实操

标签:

更新时间:2026-08-26 23:33:15

上一篇:Word文档创建时间修改时间更改方法原因及解决

下一篇:微信多开bat安全使用注意事项_实操演示_安全使用建议