Default theme only works in maintenance mode

Hello,

First time using farmOS installed in my own personal computer. Everything in the installation seemed to be ok but when I enter to the dashboard (ar any other page) the default theme is not applied:

But when I put the site into maintenance mode, the theme is correctly applied.

Any hint of what could be going on?

1 Like

It could caused by a number of issues.

Things to check:

  1. File permissions
  2. settings.php config
  3. Are you using any kind of reverse proxy?

Itā€™s worth looking through this page, if you havenā€™t already Installing farmOS | farmOS

And remember to clear caches after trying any fixes.

1 Like

Hi Ed, thanks for answering.

  1. Public, private and tmp file system path directories were set to chmod 777. I had tried 775 but it was not sufficient to pass all the errors in the Requirements page prior installation. Is there any other directory I should check permissions?
  2. What should I look specifically in the settings.php file?
  3. Not that Iā€™m aware of. All the proxy modules are inactive on the httpd.conf file and there are no other proxy configurations.

Checking the Installing farmOS page:

  • I believe I have all the system requirements checked.
  • Iā€™m using a packaged release: 3.2.2.
  • I have tried clearing cache multiple times with no luck.
2 Likes

@bejuco Can you describe your setup in a little more detail? Are you hosting in Docker? Is the host OS Linux/Mac/Windows?

Of course. I have a Linux machine (kernel v.6.6.37 LTS) using EndevourOS. Iā€™m using apache (2.4.61), php (8.3.9) and mariadb (11.4.2).

  • First I created a database, a user and a password for farmOS using maridb.
  • I didnā€™t use Docker. I installed the farmOS codebase directly on the host server (specifically on the /srv/http directory) using a packaged release tarball (v3.2.2).
  • Then I configured apache to use a VirtualHost (to be able to run different sites on different ports like this example) with this configuration:
<VirtualHost 127.0.0.1:85>
	ServerName goyita-farmos.com
	DocumentRoot "/srv/http/farmOS/web"
	<Directory "/srv/http/farmOS/web">
		Options FollowSymLinks
		AllowOverride All
		Order allow,deny
	    Allow from all
		Require all granted
	</Directory>
</VirtualHost>
  • Finally I got into the installation page and resolved all the requirements errors (missing php modules, non-writable or non-existent directories, etc.)

I did try to create a development environment but whenever I ran docker compose up -d and opened http://localhost, the broser had a ā€˜Connection was resetā€™ error page. So I stopped trying. I think there is a conflict between the docker-proxy service and apache.

1 Like

@bejuco Thanks!

Thatā€™s interesting that it works when you are in maintenance mode. It may be that maintenance mode disables ā€œCSS/JS aggregationā€, which I suspect is whatā€™s causing your problem. You can test that yourself by going to /admin/config/development/performance and unchecking both boxes in the ā€œBandwidth optimizationā€ section. (This is also where you can manually clear caches via the button at the top.)

If turning off CSS/JS aggregation fixes the problem, then that indicates that Drupal is unable to write CSS and JS files to your public files directory for some reason (usually permissions). So I would double check that. This looks like it describes what the permissions should be succinctly (and links to the much longer Drupal docs page for more details): 7 - What are the recommended directory permissions? - Drupal Answers

I wouldnā€™t recommend leaving CSS/JS aggregation turned off as a permanent solution. It indicates that thereā€™s a deeper issue with Drupalā€™s ability to write files to the directories it needs to, which means other issues may arise besides this one.

You can also go to /admin/config/media/file-system to see how your public/private/temporary files directories are configured. That page may provide a warning/error if they are not correctā€¦ I forget.

Hope that helps!

Yep, the CSS/JS aggregation was it. I turned them off and and the theme is applied correctly. However, when I change the permissions of the different directories to the values recommended on the link you shared I get new problems.

I canā€™t toggle ON the CSS/JS Aggregation options. I get a Set up the optimized assets file system path to make these optimizations available message. I can only get rid of the message if I set 777 both on the /default and /default/files directories.

I donā€™t see any warnings or errors on the file-system page nor the status report page related to file paths.

1 Like

@bejuco Who is the owner and group of the directories? The important thing is that they are writeable by the same user that Apache uses (often www-data).

1 Like

@mstenta root in both cases. Apache is using the user/group http. So I guess I have to set permissions to that user/group?

Checking the status report page again I get a Configuration files error: The directory sites/default is not protected from modifications and poses a security risk. You must change the directoryā€™s permissions to be non-writable.

Iā€™m sorry but is a little bit confusing for me. Directories should be writable only by the owners and the user Apache uses right?

1 Like

OK if the user and group of sites/default/files is root, and the permissions are 755, that means that only the root user is allowed to write to it.

One option would be for you to change the owner and group of sites/default/files to http (if thatā€™s the user that Apache is running its workers under).

This error would be shown if you use 777 permissions. This means that ALL USERS are able to write to that directory, which is a security risk.

Correct. So you can either make the sites/default/files directory owned by http and give it 755 permissions, or you can make it owned by root (or some other user) with a group of http and 775 permissions. I prefer to just make it owned by www-data in my case (http in yours).

1 Like

@mstenta Just configured the folders to be owned by root and with a group of http with 775 permissions. Still no luck. When I toggle ON the CSS/JS Aggregates, the theme is not applied. Maybe is something that must be done prior the installation process?

What other issues could arise if I left the aggregates turned off?

1 Like

@bejuco Are you 100% sure that Apacheā€™s workers are running as the http user? Is it possible that it is actually www-data (this is most common in my experience, but can vary based on distro, and Iā€™m not familiar with EndeavorOS). Iā€™m not sure what else could cause the problem.

Nope. Iā€™ve helped people debug this problem many times. It is almost always a permissions issue (or something weird because of Windows hosts related to permissions), and once the permissions are corrected it works. You do not need to reinstall.

BUTā€¦ you may need to clear the cache! And by that I mean Drupalā€™s cache, which I pointed to in a previous comment. There is a button in the Performance configuration page to do so. After you change the permissions make sure you clear the cache and then turn on aggregation.

What other issues could arise if I left the aggregates turned off?

Aggregation turned off isnā€™t a big issue by itself. It will reduce your performance because youā€™ll be loading potentially dozens of separate CSS+JS files with each request, instead of 1 or 2.

The bigger issue is that Drupal canā€™t write files. This means you canā€™t upload anything to farmOS. No photos, documents, CSV imports, etcā€¦ There may be other important things that Drupal needs to write other than that, Iā€™m not sure.

If your site is not publicly exposed to the internet, then maybe you donā€™t need to worry about setting perms to 777. But I prefer to do things correctly and understand ā€œwhyā€ something is or isnā€™t working properly, so it can be fixed properly.

Hi @mstenta. Iā€™m sure. The httpd.conf has

User http
Group http

and this is the output of ps aux | grep -E '(apache|httpd)':

Summary
root         721  0.0  0.1 397680 28832 ?        Ss   16:39   0:00 /usr/bin/httpd -k start -DFOREGROUND
http         786  0.0  0.2 400360 34740 ?        S    16:39   0:00 /usr/bin/httpd -k start -DFOREGROUND
http         787  0.1  0.2 404676 46980 ?        S    16:39   0:00 /usr/bin/httpd -k start -DFOREGROUND
http         788  0.0  0.2 402312 36504 ?        S    16:39   0:00 /usr/bin/httpd -k start -DFOREGROUND
http         789  0.0  0.2 400264 34680 ?        S    16:39   0:00 /usr/bin/httpd -k start -DFOREGROUND
http         790  0.0  0.2 402312 36664 ?        S    16:39   0:00 /usr/bin/httpd -k start -DFOREGROUND
http        3002  0.0  0.2 402312 36616 ?        S    16:40   0:00 /usr/bin/httpd -k start -DFOREGROUND
http        3051  0.0  0.0 397924 10404 ?        S    16:40   0:00 /usr/bin/httpd -k start -DFOREGROUND
http        3052  0.0  0.0 397924 10404 ?        S    16:40   0:00 /usr/bin/httpd -k start -DFOREGROUND
http        3053  0.0  0.0 397924 10404 ?        S    16:40   0:00 /usr/bin/httpd -k start -DFOREGROUND
http        3054  0.0  0.0 397924 10404 ?        S    16:40   0:00 /usr/bin/httpd -k start -DFOREGROUND
pierre      3305  0.0  0.0   9024  2288 pts/0    S+   16:42   0:00 grep --color=auto -E (apache|httpd)

I did clear the Drupalā€™s cache. Every time I change chmod I restart apache, clear browser chache and Drupalā€™s cache with that button.

But I have been able to upload files in farmOS. I did it with various .geojson for land assets and a .jpeg for a plant type. They are in the /sites/default/private/files/farm directory :thinking:

I was thinking about that. Itā€™s gonna be a local project so Itā€™s not that bad. But I agree with you, Iā€™d prefer to know everything is correctly set.

1 Like

Huh! Well Iā€™m stumped then. I assumed that file uploads didnā€™t work too. :thinking:

Could it be that the sites/default/files/css and js directories specifically have the wrong owner/permissions? Those are where Drupal writes the aggregated files so they can be loaded quickly.

Well, those directories donā€™t exist! In the sites/default/files directory thereā€™s only a config_zQvXnUZ... folder and a php folder. Maybe thatā€™s the problem?

1 Like

Oh. Wellā€¦ Drupal should create those directories itself, on-demand I believe. And as long as Apache can write to the parent directory it should be able to do that. You could try creating them yourself (and make them writable by Apache) and see if that allows you to turn on aggregation. Still curious why it didnā€™t create them itself thoughā€¦

I tried creating the directories but when I clear Drupalā€™s cache, they are deleted, both with CSS/JS aggregate on and off.

1 Like

Hmm OK. Iā€™m skimming through an issue on Drupal.org that might help, starting with this comment:

https://www.drupal.org/project/drupal/issues/3381293#comment-15206160

There are a few comments that follow from there that might be worth trying in your environment.

Someone describes an issue (in their case it was Nginx, not Apache), where Nginx was sending the requests directly to the filesystem for the aggregated files, rather than letting Drupal process them, thus Drupal never got the chance to create them. Not sure if the same thing is happening in your case.

Please let me know if you figure it out. It might be helpful to add something to farmOS docs if itā€™s a missing configuration.

1 Like

Thanks for all your help @mstenta. Iā€™ll let you know any workaround.

1 Like

Iā€™m having the same issue with a fresh install of FarmOS 3.2.2 on Ubuntu 24.04. Do install, do the initial configuration, and the webapp renders with just text as shown above. I also didnā€™t have the /var/www/html/farmOS/web/sites/default/css or /var/www/html/farmOS/web/sites/default/js directories. I created them and chown/chmod to match the default dir. Did the drush cr and restarted apache2. No love.

Looking at the access log, all the GET calls for css and js files return a 404.

Whatā€™s also odd is that none of the links workā€¦ on the page. All return 404.