ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Template caching and PHP ownership

September 02, 2009 3:10pm

Subscribe [4]
  • #1 / Sep 02, 2009 3:10pm

    paulp

    38 posts

    We’re experiencing extremely high load on our server, due mostly to the db queries with our EE site. I’m trying out some of the optimization methods described in the docs and Wiki, but I’m encountering some problems with template caching.

    I’ve noticed that the cache folders (page_cache, db_cache, etc.) are all owned by apache, and they don’t write the sub-folders unless I change ownership of the cache directories.

    Now that I’ve changed ownership of the cache directories, I’m seeing many sub-directories getting creating constantly, but they’re all empty, and they’re all owned by apache. Are these directories supposed to be empty or filled with cached files?

    I’m assuming the problem is that PHP is assigning ownership of these directories to apache, which doesn’t have write access. Is this correct? I’m trying to resolve this issue with my host but they don’t seem to understand the problem and correspondence is very slow.

    Any advice?

    Thanks!
    Paul

  • #2 / Sep 02, 2009 4:20pm

    Ingmar

    29245 posts

    All cache directories should have 777 permissions. That way, ownership of the file should not be an issue.

  • #3 / Sep 02, 2009 4:24pm

    paulp

    38 posts

    That’s what is confusing me. They are all set to 777. When the cache directories are owned by apache they don’t get written with the cache files. When they are owned by “bustler” they get written. The problem is that all the dynamically created sub-directories in the page_cache, db_cache, etc. folders are all owned by apache and are empty.  I have doubly confirmed that they all have permissions of 777.

  • #4 / Sep 02, 2009 4:28pm

    Ingmar

    29245 posts

    It still sounds like a permissions issue. Does the main “cache” directory have the necessary permissions as well? With 777 permissions, any user should be able to write there, as you know.

  • #5 / Sep 02, 2009 4:52pm

    paulp

    38 posts

    All cache folders have been set to 777.

  • #6 / Sep 02, 2009 4:56pm

    Ingmar

    29245 posts

    It might be some issue with how your server (PHP in particular) is configured. Have you talked to your host about it?

  • #7 / Sep 02, 2009 8:08pm

    paulp

    38 posts

    Thanks for your input Ingmar. I’m at a loss. I’m not getting anywhere with my hosting company and our server’s getting slammed with queries. Is changing the PHP configuration the solution, and this is something that only the web host can do?

  • #8 / Sep 02, 2009 8:23pm

    paulp

    38 posts

    Hopefully this information from my host will shed some light on the problem:

    777 is full read/write/execute permissions to owner/group/world.  That means that every user on the entire server has full access to that directory.

    While that is true, the cache certainly isn’t getting created….although if I change the owner/group, it does get created. 777 is wide open though so this should not be preventing anything from getting created…it can’t be more open than that.

    For example, I changed the apache user’s shell to /bin/bash so that I could su to that user and test it out:

    [root@vps page_cache]# su apache
    bash-3.2$ pwd

    /.../httpdocs/system/cache/page_cache
    bash-3.2$ ls
    012ced864a34e9f4fec06ea14ae97fe1 5d0eceec25679c23a48224cf4e6ea129 b76acd52747dfcd94c8a2e33da74b0ea
    0d7e67497f453e7b499f4c2013c1212e a518ca3de7fdd4b2994aa778f8bff895 eddc84f51bce6d5f93125886b91a856e
    59f171d7601c4952328881856777880c a6bce2a9346532197bc02eac6e4ecba6
    bash-3.2$ cd 012ced864a34e9f4fec06ea14ae97fe1/
    bash-3.2$ ls
    bash-3.2$ touch test
    bash-3.2$ ls
    test

    The apache user most certainly can write files there.  So why isn’t caching working then unless the directories are chown’d to bustler/psacln?  Well that’s a pretty good question.

  • #9 / Sep 02, 2009 9:31pm

    Greg Aker

    6022 posts

    Looks like you’re on plesk with the psacln group in there.  This is an interesting one.  Can you jump in and look at the domains apache error log?  I’m reaching here, but am wondering if we have any openbase_dir() errors in your log. 

    Let’s have you go in & wipe the sub-folders out of the cache directory.  quadruple check to make sure the cache folder has permissions of 777 and hit the home page of your control panel.  At the least you should have a magpie cache folder.  If it’s empty, check those logs so we can see if there are any clues in there.

    -greg

  • #10 / Sep 02, 2009 9:34pm

    paulp

    38 posts

    5 seconds before you responded my host resolved the problem. The problem was that the server was running in Safe Mode.

    Thanks to Inmar and Greg for the support. Out of curiosity, is there a way to confirm that certain templates are getting cached?

    Paul

  • #11 / Sep 02, 2009 9:45pm

    Greg Aker

    6022 posts

    Ah yes!  a good thing to remember when you’re setting up your domains in a hosting control panel like Plesk is to turn off php safe mode if you can!

    As for confirming caching, you can peek at the page_cache folder and see pages in there. What kind of traffic are we talking about?  How hard are you getting slammed?

    You may want to consider looking at the Static Page Caching module from Solspace.

    -greg

  • #12 / Sep 02, 2009 9:48pm

    paulp

    38 posts

    the page_cache folder is showing tons of folders that now have files in them. so it’s safe to assume that all templates that are set to cache in the template preferences are now caching properly?

    we have around 50,000 uniques a day and LOTS of interactivity using native EE features and 3rd party extensions (mostly Solspace modules).

  • #13 / Sep 03, 2009 1:33am

    John Henry Donovan

    12339 posts

    paulp,

    the page_cache folder is showing tons of folders that now have files in them. so it’s safe to assume that all templates that are set to cache in the template preferences are now caching properly?

    It looks that way yes. As Greg suggested take a look at the Static Page Caching module from Solspace.

    Other than that it seems your issue is sorted. Are you happy for me to close the thread for you?

  • #14 / Nov 24, 2009 4:20pm

    enbroaden

    38 posts

    I have a question - I was having the exact same issue: pages not caching - and I saw your post and turned safe mode off, and suddenly the site wouldn’t load!  I turned safe mode back on but now it still won’t load!  Help!

  • #15 / Nov 24, 2009 4:24pm

    Ingmar

    29245 posts

    rapturestudio, let’s keep it to the original thread, shall we? I’ll be over there in a minute; closing this old one out.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases