我的知识记录

Nginx Apache_Nginx HTTP转HTTPS配置

Nginx HTTP转HTTPS的排查流程:配置语法检测 → 服务状态(systemctl status)→ 错误日志(error.log)→ 端口监听(netstat)→ 权限和路径 → 后端服务状态。按流程走,Nginx/Apache问题10分钟内能定位。

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

参考(Apache配置与排查): ``` # 语法检测 apachectl configtest httpd -t

# 重载与重启 systemctl reload httpd systemctl restart httpd

# 查看模块 httpd -M | grep rewrite httpd -M | grep ssl

# 错误日志 tail -50 /var/log/httpd/error_log tail -50 /var/log/apache2/error.log

# .htaccess示例 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

# 虚拟主机配置 ServerName 域名 DocumentRoot /var/www/域名 AllowOverride All Require all granted ErrorLog logs/域名-error_log CustomLog logs/域名-access_log common ```

排查完用nginx -t检测确认。nginx -t返回syntax is ok,systemctl status显示active (running),curl -I返回200,浏览器访问正常。错误日志没有新的error记录。所有location和rewrite规则测试通过。

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

Nginx Apache_Nginx HTTP转HTTPS配置

标签:

更新时间:2026-08-26 21:51:01

上一篇:修改Word文件创建时间修改日期不用插件|合同文档归档原生Word 2013文档时间属性调整

下一篇:thinkphp多应用模式入口文件设置_public目录下多入口文件管理