我的知识记录

虚拟主机部署问题_修复实操

万网虚拟主机服务器用Nginx或Apache遇到部署问题,先做配置语法检测。Nginx用nginx -t,Apache用apachectl configtest,语法通过再重载。部署问题时80% 是配置语法错或路径错,检测工具能直接指出错误行号。

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

参考(Nginx反向代理与性能): ``` # 反向代理 server { listen 80; server_name 域名; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_read_timeout 300s; proxy_connect_timeout 30s; } }

# 性能优化(nginx.conf http块) worker_processes auto; events { worker_connections 10240; use epoll; multi_accept on; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; gzip on; gzip_types text/css application/javascript image/svg+xml; gzip_min_length 1024; open_file_cache max=65535 inactive=60s; }

# 静态资源缓存 location ~* .(css|js|png|jpg|jpeg|gif|ico|svg|woff2?)$ { expires 30d; add_header Cache-Control "public, immutable"; } ```

Nginx性能优化:worker_processes auto(和CPU核数一致)、worker_connections 10240、keepalive_timeout 65、gzip on、sendfile on、tcp_nopush on、open_file_cache缓存文件描述符、静态资源expires 30d。优化后并发连接数提升5-10倍,高并发场景必备。

Nginx错误日志速查:"emerg" 配置语法错(nginx -t看行号)、"alert" 权限问题、"crit" 资源不足、"error" 一般错误(404/403/502)、"warn" 警告。日志级别在error_log指令设置,生产环境用warn或error,调试用debug。

虚拟主机部署问题_修复实操

标签:

更新时间:2026-08-27 00:46:16

上一篇:网站备份前先导出邮件列表_虚拟主机实用教程

下一篇:403 Forbidden_CDN WAF与源站403区分