We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44866
    • 50 Posts
    Hi Guys,
    I'm finding some inconsistencies with clearing the cache programmaticly or from the Management Console on my dev server. (Revolution 2.2.6)

    After running a cron job that contains this line.

    $modx->getCacheManager()->refresh();


    my web pages are stuffed up and display all weird. At least I think that line is the cause.

    If I clear the cache manually by physically deleting all the files and sub directories in core\cache\ the pages then load correctly again. If I run the command from the management console "Site -> Clear Cache" it has no effect on the broken pages.

    My first guess is this is a file permissions problem as I'm manually logged on as root when I clear the files.
    When I look a the files and folders there seems to be a mixture of owner and group names between root, wwwroot and www-data
    The actual permissions seem to be all over the place.

    ps -ef shows that www-data is the user running apache2.

    Is there a description somewhere of what the correct permissions should be for all my files and directories under /var/www?
    Mine were probably stuffed up when I imported stuff from my production server into development.

    Thanks
    David


      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That depends on your web server/PHP configuration. If you are using some form of su_exec user switching, then they need to be owned by the user to switch to - usually an FTP/SFTP user. Permissions are usually 755 and 644 in such a case.

      However, on a dedicated server or VPS, that's not only not beneficial but possibly harmful. So the files and folder should belong to the web server user, www-data, and permissions can be 777 and 666 for the folders and files that other users, such as FTP/SFTP users, will want to access as well.

      Keep in mind that a file uploaded via FTP will be owned by the FTP user, so the www-data user needs permission, and a file uploaded via MODX will be owned by the web server (or the PHP user, depending on your site's configuration) and will need to be accessible to the FTP user.

      The last time I had a VPS, I gave my SFTP user the same group as my web server and the PHP-FPM user, and used 775 and 664 permissions. You need to specifically create the folder and file permission settings in the System Settings for MODX or it will use its hard-coded default of 755 and 644.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org