Drupal 7 开发内部培训资料, 分头诗人

drupal 8安装完成后无法正常加载CSS/JS样式,无法显示后台和前台主题,检查后发现500错误

赞成!
0
否决!

安装环境:centos 7.2.1511+ Apache 2.4.18+ Php 7.0.3+ MariaDB 10.1.12+ drupal-8.0.5;suphp模式。
问题描述:全新安装drupal 8后无法正常加载CSS/JS样式,管理主题只能显示竖排的文字内容,通过chrome浏览器的检查功能发现/sites/default/files文件夹下面的CSS/JS返回500错误[Failed to load resource: the server responded with a status of 500 (Internal Server Error)],当通过Administration > Configuration > Development > Performance路径取消合并压缩CSS/JS后,整个网站显示正常。
排错诊断:初步怀疑有两种可能,一是drupal 8的一个bug,讨论详见https://www.drupal.org/node/2619250,目前没有解决方案;二是apache的httpd.conf需要配置Mod_Rewrite模块并允许AllowOverride  MultiViews,参考代码为:
<Directory />
  Options FollowSymLinks
  AllowOverride AuthConfig FileInfo Indexes Limit Options=All,MultiViews
  Order deny,allow
  Deny from all
</Directory>
求助内容:有没有其他人遇到类似的问题,有没有好一点的解决方案,比如不动服务器配置。

5 个回答

赞成!
0
否决!

查看了服务器的apache配置,怀疑是这段代码的问题,奇怪的是,我启用multiviews后还是不行
<Directory /home>
AllowOverride All
Options --MultiViews -Indexes +FollowSymLinks +IncludesNoExec +Includes
<Limit GET POST OPTIONS PROPFIND>
  Order allow,deny
  Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
  Order deny,allow
  Deny from all
</LimitExcept>
</Directory>

赞成!
0
否决!

希望有高手帮忙

赞成!
0
否决!

给一个配置你看

VirtualHost *:80>
                ServerName www.mydrupal.co
                DocumentRoot /var/www/drupal

                # Redirect http to https
                RedirectMatch 301 (.*) https://www.mydrupal.co$1
        </VirtualHost>

        <VirtualHost _default_:443>

                # Server Info
                ServerName www.mydrupal.co
                ServerAlias mydrupal.co
                ServerAdmin webmaster@localhost

                # Web root
                DocumentRoot /var/www/drupal

                # Log configuration
                ErrorLog ${APACHE_LOG_DIR}/drupal-error.log
                CustomLog ${APACHE_LOG_DIR}/drupal-access.log combined

                #   Enable/Disable SSL for this virtual host.
                SSLEngine on

                # Self signed SSL Certificate file
                SSLCertificateFile      /etc/apache2/ssl/drupalssl.crt
                SSLCertificateKeyFile /etc/apache2/ssl/drupalssl.key

                <Directory "/var/www/drupal">
                        Options FollowSymLinks
                        AllowOverride All
                        Require all granted
                </Directory>

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>

                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                # MSIE 7 and newer should be able to use keepalive
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

        </VirtualHost>
赞成!
0
否决!

另外看看权限方面是否对了,设置你的网站文件夹为www 指定的用户

cd /var/www/
chown -R www-data:www-data drupal/

 

 

改/sites/default/files 权限

chmod a+w *

如果还不行,尝试重新安装drupal,在安卓的时候,会检查环境的,看看是否哪不满足了

最后还可以查看日志,看看是否有什么错误提醒

赞成!
0
否决!

apache 的错误提示是:[Sat Mar 12 13:37:04.893740 2016] [core:alert] [pid 7627:tid 140672560412416] [client 58.48.17.28:54522] /home/xxxx/domains/xxxx.com/public_html/sites/default/files/.htaccess: Option ExecCGI not allowed here, referer: http://www.xxxx.com/

谢谢诗人,问题已经找到,directadmin的配置比较复杂,之所以出现这样的问题是因为CGI被禁止了。也就是说在directadmin环境,要让drupal8顺利运行,必须同时允许php和cgi程序