php - SilverStripe 3:无法再访问 CMS 管理区域,收到 500 错误
问题描述
当尝试通过 /admin 访问实时 SilverStripe 站点上的 CMS 时,它突然开始生成 500 错误页面,并显示以下消息,站点的其余部分很好:
服务器遇到内部错误或配置错误,无法完成您的请求。
public_html 文件夹中的错误日志中的最新错误显示:
[17-Nov-2018 03:06:11 UTC] PHP 警告:Director::protocolAndHost() 缺少足够的信息 - HTTP_HOST 未设置。在 /home/mysite/public_html/framework/control/Director.php 第 488 行
cPanel 中的错误日志显示:
[2018 年 11 月 21 日星期三 15:27:24.578366] [core:alert] [pid 10504:tid 47515481941760] [client 90.242.226.###:56737] /home/bwib/public_html/.htaccess: 无效命令 'SetEnv' ,可能拼写错误或由未包含在服务器配置中的模块定义
我检查了 .htaccess 文件,它以某种方式更改为:
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
php_value date.timezone "UTC"
</IfModule>
# END cPanel-generated php ini directives, do not edit
如果我用原始的 .htaccess 文件替换它,整个站点就会中断,我会收到 500 错误。
原始 .htaccess 在这里:
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
# Deny access to IIS configuration
<Files web.config>
Order deny,allow
Deny from all
</Files>
# Deny access to YAML configuration files which might include sensitive information
<Files *.yml>
Order allow,deny
Deny from all
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
<IfModule mod_dir.c>
DirectoryIndex disabled
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/'
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
银条尾
托管公司不愿意建议或帮助调查,只是一直告诉我“管理文件夹是空的”非常无益。
一些研究为我指明了这些答案的方向,但我不确定如何通过 cPanel 或 .htaccess 文件应用这些答案:
Director::protocolAndHost() 缺少足够的信息 - HTTP_HOST 未设置
https://github.com/kanboard/kanboard/issues/2685
附上服务器设置的屏幕截图:
关于如何解决这个问题的任何建议都会很棒!
解决方案
如果您使用 FTP 和 SSH,则切勿使用提供商的 CPanel,反之亦然。
您不能更改 php 中的所有 Apache 设置,这不是一回事。
删除SetEnv
,因为您肯定没有专用服务器。所以不SetEnv
适合每个人,因为它很危险。
在 .htaccess 中,最好检查 mod_rewrite 是否启用:
<IfModule mod_rewrite.c>
# Enable URL rewriting
RewriteEngine On
# All the rewrite conditions and redirections below
</IfModule>
推荐阅读
- python - Python停止在特定条件下增加列表
- user-agent - 如何找到应用程序的用户代理,并在桌面浏览器中使用它?
- python - 使用多个条件从 Xpath 中的元标记中提取内容
- mysql - 如何从外部查询中获取与组相关的小计?
- java - 当我将布局更改为不可见时如何修复 ClassNotFoundException
- java - 如何阻止 Java 自动将 char 值转换为 int?
- laravel-5 - 如何在 updated_at` 字段中设置 null?
- c++ - 由于引用,重载的调用不明确
- regex - 限制 XSD 中的字符串,使它们没有前导或尾随空格,并且只包含字母数字、连字符和下划线?
- java - 如何让 vert.x 项目在 Docker 容器中工作?