Silverstripe安装-友好的URL不起作用

时间:2018-09-17 18:35:36

标签: silverstripe silverstripe-4

我尝试在两台不同的服务器上安装silverstripe 4.2.1,并在安装时遇到相同的错误。今年我在其他客户端计算机上进行了多次安装,但这是我第一次遇到此问题。想知道这是否是4.2.1问题

安装错误消息

  

友好的URL无法正常工作。这很可能是因为您的站点上未正确配置重写模块。您可能需要让您的Web主机或服务器管理员为您执行此操作:

     

您的Web服务器上启用了mod_rewrite或其他重写模块
  为SilverStripe所在的目录设置AllowOverride All。   已安装

我在.htaccess的根目录,public_html和silverstripe公用文件夹中放置了一些垃圾文本。这三个都会导致500错误。

请注意,我能够访问site.com,并将其重定向到安装程序。所以我认为确实启用了mod_rewrite。

当我访问site.com时,它会显示银色的“服务器错误”版本

我的HTAccess文件位于SS的公用文件夹中:

$ emerge $(find /usr/portage/sys-apps -maxdepth 1 -type d | tail -n +2 | sed 's,/usr/portage/,,')

还有一个位于public_html

    ### 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 ###

我正在共享服务器上运行PHP7.1。

1 个答案:

答案 0 :(得分:1)

如果有人遇到此问题,我想在此发布。它困扰了我四天,似乎没人能回答。

如果通过将源文件解压缩到public_html或由composer在共享主机帐户上安装SS,则安装时可能会出错。

无法编写友好的url-检查是否启用了mod_rewrite并将AllowOveride设置为All。

我知道在与技术支持人员交谈后,实际上两者都已启用。

在安装错误后访问该站点时,经过一些测试可以看到该站点确实按照SS的意图重写为/ public时,我会收到服务器错误消息。

最后,我注意到/public中的index.php拥有775的权限。我将其更改为644,一切都很好。

注意:我尝试在两个不同的主机提供程序上安装v4.2.1。 BlueHost(对作曲者具有ssh访问权限)和Hostgator(无ssh)都给了我同样的问题