Permission(?) issues on local dev environment using WSL

I’ve been having a lot of trouble getting a MODX 2.8.4. site to properly run locally under Windows Subsystem for Linux (WSL) using Ubuntu 22.04, Apache2, mariadb and PHP 8.

Most of my issues are:

  • php errors like can’t open/find file or directory
  • image thumbnails not loading in media browser
  • (and now even) blank manager page → 500 error

I’m guessing this comes down to permission/ownership issues and by now through trying different things, I’m afraid it’s messed up quite a bit. I’m wondering, if there’s someone here (maybe even using the same environment) that can point me in the right direction to fix things?

I have tried resetting all folders and files permissions using:

find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;

And this is a print of my web root using ls -l:

drwxr-sr-x 1 www-data www-data   512 Dec  9 18:01 assets
-rw-r--r-- 1 www-data www-data   299 Dec  9 17:59 config.core.php
drwxr-sr-x 1 www-data www-data   512 Apr 28  2022 connectors
drwxr-sr-x 1 www-data www-data   512 Jan 11 15:24 core
drwxr-sr-x 1 www-data www-data   512 Dec 13 12:21 images
-rw-r--r-- 1 www-data www-data  1893 Apr 28  2022 index.php
drwxr-sr-x 1 www-data www-data   512 Dec  9 19:38 manager

Which looks right to me, but currently I’m still locked out of the manager by a 500.

Any help is highly appreciated.

Generally, MODX likes to have file permissions at 644 and folder permissions at 755. It’s fairly rare to need anything else. If that didn’t solve the problem, it’s probably not a file permission issue.

On some servers, file ownership can be an issue.

500 errors are most often caused by either a problem with .htaccess (you did rename ht.access to .htaccess, right?) or a PHP error in a plugin.

You can check the MODX error log in core/cache/logs but it usually won’t show anything when you have a 500 error. You might get a clue from the server’s error log.

Thanks for getting back to me!

I have changed that also during trying to fix things, but I’m quite sure everything belongs to www-data now, is this not correct?

I did.

Here’s the errors from the server:

[authz_core:error] [pid 316] [client] AH01630: client denied by server configuration: [...]/core/docs/changelog.txt

[php:error] [pid 362] [client] PHP Fatal error:  Uncaught  --> Smarty: unable to create directory [...]/core/cache/mgr/smarty/default <-- \n  thrown in [...]/core/model/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 51

I’m still pretty sure it’s permission or ownership related (also because that’s the last thing I changed before the 500). Still not sure what to change it (back) to now, though. Does the provided information give any more clues?

You can ignore the first error.
I believe the request to “changelog.txt” is done my MODX to check if the core folder is protected.

In the second error, the code from the Smarty library tries (in vain) to create a new directory in the cache folder (/core/cache/).
This could indeed be a permissions issue.

But what permission would be right? I double checked and the core/cache folder is also owned by the www-data user and belongs to the www-data group. Should it be something else?

I got it working again, but I’m not sure what finally solved it as I basically did nothing I haven’t mentioned here already. For anyone who might have similar issues, here are some things to check:

  • chmod all folders to 755
  • chmod all files to 644
  • chown everything to the webserver user (in my case www-data)
  • restart apache service apache2 restart

You can also double check the apache user that is running things by executing a file with:

echo `whoami`;    // www-data