【发布时间】:2019-02-21 17:44:39
【问题描述】:
我尝试在两台不同的服务器上安装 silverstripe 4.2.1,但安装时遇到相同的错误。今年我在其他客户端机器上安装了多个,但这是我第一次遇到这个问题。想知道是不是4.2.1的问题
安装错误提示
友好的 URL 不起作用。这很可能是因为您的站点上未正确配置重写模块。您可能需要让您的网络主机或服务器管理员为您执行此操作:
您的网络服务器上启用了 mod_rewrite 或其他重写模块
为 SilverStripe 所在的目录设置了 AllowOverride All 已安装
我在 .htaccess 的根目录、public_html 和 silverstripe 公用文件夹中放置了一些垃圾文本。这三个都会导致 500 错误。
请注意,我能够访问 site.com 并将其重定向到安装程序。所以我认为确实启用了 mod_rewrite。
当我访问 site.com 时,它给出了“服务器错误”的 silverstripe 版本
我的HTAccess文件位于SS的public文件夹中:
### 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 ~ "\.ya?ml$">
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
DirectorySlash On
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/public'
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule ^\.env - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteRule (error|silverstripe|debug)\.log - [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.
# Try finding framework in the vendor folder first
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
</IfModule>
### SILVERSTRIPE END ###
还有 public_html 中的那个
RewriteEngine On
RewriteRule ^(.*)$ public/$1
我在共享服务器上运行 PHP7.1。
【问题讨论】:
-
您的服务器上似乎没有启用
mod_rewrite。您必须在 apache 或 virtualhost 配置中启用此功能。根据stackoverflow.com/a/9021523/4137738,您可以使用in_array('mod_rewrite', apache_get_modules());在一个小的PHP脚本中仔细检查这一点 -
100% 启用
标签: silverstripe silverstripe-4