Sage 9 on WPEngine

So I just got word from a senior WPE tech saying they aren’t going to allow these NGINX before in-rules anymore due to security problems that could potentially arise with other users installs.
But in that frustrating discussion, he pointed me to the simplest solution I’ve found for generating these cache files on production.

Here’s an email from the tech:

I’m still looking into this myself to see what I can find, but I think one potential solution would be to change where the cache files are compiled. To explain a bit more specifically on why this won’t work, we have some restrictions in place that prevents writing to php files unless the user is authenticated. Since the cache files are being stored at wp-content/uploads/cache/*.php, that’s why it’s running into this problem. Here’s where I was able to find that defined in wp-content/themes/sage/config/view.php:

/*
|--------------------------------------------------------------------------
| Compiled View Path
|--------------------------------------------------------------------------
|
| This option determines where all the compiled Blade templates will be
| stored for your application. Typically, this is within the uploads
| directory. However, as usual, you are free to change this value.
|
*/

'compiled' => wp_upload_dir()['basedir'].'/cache',

If we’re able to switch that directory to /tmp, I think this should work without any custom rules being required. I’m looking into the theme documentation to see if that may be an easy change, but wanted to run this by you in case you may know of an easy way to do this.

So just now, I changed that ‘compiled’ directory to ‘/tmp/sage-cache’ and voila, no permission issues and I’m able to generate cache after pushing a theme up to a WPE production install.

EDIT: I’ve noticed with some of the older sites I’ve built, that the config/view.php directory and file don’t exist. Looks like this change was made about 4 months ago so your sage theme will have to have been created after that change happened for this fix to work.

This is huge for me as I’ve pushed several of these sites on to WPE and have had to deal with a chat agent every time.

Hope this helps fellow Sage/WPE users,

Good luck!

16 Likes