1

I'm working on a small D8 site. When turning the option "Aggregate CSS files" (admin/config/development/performance) on localhost, everything works fine. However, doing so when on my test server completely breaks the site presentation, both on the front (public pages) and back-end (admin).

It appears that when this option is on, the URL for the aggregated CSS is incomplete: the filename is not present, as well as most of the path, actually. Which means I have something like:

<link rel="stylesheet" href="/dpfolder/?okfo8d" media="all" />
<link rel="stylesheet" href="/dpfolder/?okfo8d" media="all" />

(the site lives in "dpfolder", although it's temporary.)

This happens with both the admin theme (seven) and the public theme (a custom theme based on Classy).

And it only happens when the option "aggregate" is ON. When it's OFF, everything displays fine (but then the CSS files are included via @import rules in a style element, and not via a link element like above).

Any idea what's causing this?

1
  • 1
    Not sure but if i guess you can check folder permission and public media directory set up.
    – DRUPWAY
    Commented Jan 27, 2017 at 12:38

2 Answers 2

2

As a comment suggested, sounds like your server does not have a writable files folder. That folder should and is by default excluded from git, you need to create it and make sure that the apache user (or whatever user the processes run as) has write permissions to that.

2
  • Thanks. I think that's already the case... But I'll check again next week.
    – s427
    Commented Jan 27, 2017 at 19:46
  • I have added the 775 permission to the default folder still css not working in Aggregate mode ON Commented Aug 28, 2018 at 10:50
0

I know this is old, but if anyone else has this problem here what I needed to do:

Following this guide: https://www.tecmint.com/install-drupal-in-centos-rhel-fedora/ I realized I was running SELinux, so there's an extra step to make the files directory writable:

13. Importantly, set the SELinux rule on the folder “/var/www/html/drupal/sites/” as below:

~ chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/sites/

This allows the sites directory to be writable. You should never have the permission set to 777 for a production server. Instead use:

~ chmod 770 -R /var/www/html/drupal/sites/
~ chown root:webgroup -R /var/www/html/drupal/sites/

Where webgroup has any users (maybe a developer) and apache.

~ groupadd webgroup
~ usermod -a -G webgroup apache

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.