We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49665
    • 3 Posts
    I've only been working with MODX since July '14 and I still feel pretty new to it, so any clues at all would be fantastic. (This is also my first time posting in the community!) Here it goes...

    I'm experiencing a strange issue in regard to snippets. For reasons I am unable to identify, at various intervals my MODX install will stop rendering/executing snippet code. The static (chunk and non-snippet template) portions of the page will usually render, but it will be void of any snippet content (e.g. Wayfinder menus, SimpleSearch boxes, getResources content, etc.). This happens both on my production server (more traffic) as well as my cloned test server (little traffic).

    I'm running:
    CentOS 6.5
    nginx 1.4.6
    MODX 2.2.14-pl

    This issue is sometimes accompanied by entries in the MODX error log relating to caching (of snippets, plugins, & lexicon entries), e.g.
    (ERROR @ /index.php) Error caching script elements/modsnippet/102

    In the past, I've been able to resolve this by clearing core/cache manually, flushing permissions, restarting php-fpm and nginx services, and sometimes also truncating the modx_session table. However, last week both my production server and my test server suffered the condition again. My production server went back to normal using the above steps, but the test server remains afflicted despite performing the aforementioned steps. In addition, the login box (which I assume depends on the Login snippets) does not appear when accessing the manager.

    It doesn't appear to be a permissions issue because it works fine, for several months at a time even, without changes to permissions. (It did suffer the same issue on two consecutive days last week, so I'm having trouble tracking down a cause). I've just about exhausted my know-how in MODX and need the opinion of greater MODX minds.

    Any thoughts or guidance? Too much info or too little?

    Thanks for any and all input.
      • 8274 ☆ A M B ☆
      • 222 Posts
      If you are seeing cache errors, you should check the permission on your core/cache folder. Could be that apache can't write to the folder, which I have had happen in rare instances (I have gone to using FastCGI for php processing which seems to help with server's not letting apache read/write/execute files).

      Not sure that would keep a snippet from running. Are there any errors in your browser web tools (console) regarding missing files? What about the server logs? What errors are showing in there (this is different than the MODX error log)?

      The login to the manager is not the LogIn plugin, though. So if the manager login is not showing, then there is a deeper server issue with paths or execution as that runs out of the manager directory. You certainly need to review your server error logs to see what is happening when MODX attempts to run.

        • 49665
        • 3 Posts
        Well, that was aces. I changed permissions on the cache and subfolders and the snippets showed up immediately and these entries ceased occurring in the MODX log:
        [2015-01-13 15:01:06] (ERROR @ /index.php) Error caching script elements/modsnippet/93

        Also the manager login came back and worked perfectly.

        So since the files/folders in core/cache are being written with wrong permissions, can I then assume that whatever script is writing to the core/cache folder has the wrong permissions and should be changed? (Evidently this is index.php based on the error log).

        Thanks so much for your quick and detailed and highly effective reply.

        For posterity, my PHP logs showed no irregularities during the issues (which makes sense if MODX wasn't writing the snippets to cache and thus wasn't executing any of them).
          • 8274 ☆ A M B ☆
          • 222 Posts
          I don't think it is script that is writing wrong permissions. This is typically the server and how it is set up to run PHP.

          I had to set my php handler to FastCGI to fix the issue where the server OS wouldn't allow Apache access to folders created by the default user. Otherwise I had to loosen the permissions (chmod) on the directories and that is very safe.

          Are you running your own production server or using a commercial host?
            • 49665
            • 3 Posts
            We are running our own server. The current setup was already configured and running when I came into the picture so troubleshooting is of course a little more difficult.

            We are using php-fpm (a FastCGI offshoot). Did your PHP logs show errors when the OS was denying Apache access in your case?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It is not necessary to use suexec for anything except shared hosting, and may even be problematic. http://forum.sp.parallels.com/threads/suexec-serious-security-concerns.257429/

              There is no danger in having files set to 666 and directories to 777 in VPS or dedicated servers. And you can have the web user and group be anything you want (well, not root). That's what I did when I had a VPS, I set the web user to be the same as my SSH user, making sure to use public key authentication and disabling a password login. http://lani78.com/2008/08/08/generate-a-ssh-key-and-disable-password-authentication-on-ubuntu-server/
                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