Roots Discourse

Set file permissions direct or through Trellis?

I have WooCommerce installed and it’s currently not able to write to its default log file.

WooCommerce - System Status:
Log directory writable:

To allow logging, make /srv/www/mydomain.co.uk/releases/20200309193629/web/app/uploads/wc-logs/ writable or define a custom WC_LOG_DIR .

I suspect I should not SSH in and modify the file permissions in that release directory, as it’ll change upon next deploy. Is the usual process to set the permissions via Trellis somehow?

That’s odd since it’s under the normal app/uploads dir which should be writeable otherwise no other uploads would work. Do your media uploads work as expected?

That being said, you could try setting WC_LOG_DIR to Trellis’ log dir so that all logs are in one place. Nginx logs are at /srv/www/mydomain.co.uk/logs.

You can set it under the env property on your WP site:

example.com:
  site_hosts:
    - canonical: example.com
      redirects:
        - www.example.com
        - site.com
    - canonical: example.co.uk
      redirects:
        - www.example.co.uk
env:
  WC_LOG_DIR: /srv/www/mydomain.co.uk/logs

Ideally we wouldn’t have to hardcode paths like that but there’s no good solution for that yet :frowning_face:

Thanks @swalkinshaw - Unfortunately no change so far, even the status showing where it’s trying to log files to did not change (apart from the /releases/number part). Provision went through successfully with the change in production/wordpress_sites.yml

My dev environment is working fine and has a green tick for the same log file location.

That’s odd since it’s under the normal app/uploads dir which should be writeable otherwise no other uploads would work. Do your media uploads work as expected?

Yes. I usually have S3 Uploads plugin enabled, there is no wc-logs file in there, and I then disabled the plugin and uploaded a media file locally which loaded fine. The logs are no where to be seen.

I manually SSH’d in and checked out the file permissions for the folders. I set 755 for the wc-logs, is this the correct user and file level of permissions required?

drwxr-xr-x 3 web www-data 4096 Mar 8 23:30 2020
drwxr-xr-x 2 root root 4096 Mar 12 08:25 wc-logs
drwxr-xr-x 2 root root 4096 Mar 11 12:28 woocommerce_uploads

The status page now shows green tick for the log directory (without WC_LOG_DIR set).

755 is correct but the owner should be web:www-data and not root which is dangerous.