阿里云虚拟主机Web服务器_Nginx图片缓存
很多站长遇到Nginx图片缓存直接重启服务器,配置错的重启后还是起不来。正确做法是nginx -t或apachectl configtest看报错行,修正后reload。reload不中断服务,restart会短暂中断,生产环境用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; } } ```
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-26 22:08:31
上一篇:微信电脑版五开_多用户_Win11企业版_推广_权限不足解决