Jump to:

4938 Posts in 16594 Topics by 1490 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Cache OK for http; not writable for https

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1615 Views
  • JohnHughes
    Avatar
    Community Member
    8 Posts

    Cache OK for http; not writable for https Link to this post

    I'm working on a SilverStripe installation on a Linux dedicated server.

    http access works fine; https throws [User Error] Uncaught Zend_Cache_Exception: cache_dir is not writable

    Any ideas on why we're having this problem?

    SilverStripe v.2.4.2
    During the testing phase we're using a self-signed certificate.

  • JohnHughes
    Avatar
    Community Member
    8 Posts

    Re: Cache OK for http; not writable for https Link to this post

    Changing the cache permissions to 777 makes it possible to log in using https. However, other work -- uploading photos to assets, for example -- cannot be done because the assets folder is not writable for https. I don't want to make assets 777.

    Can anyone point me to documentation that explains how to set up SilverStripe on a Linux server so that the admin interface works under https?

    I'm working on a dedicated server with WHM and cPanel, so I'm pretty much free to configure this in any way I need.

    I openly admit to being ignorant of the SSL environment requirements. However, it is supposed to be possible to set up under SilverStripe and I'd like to know how to do it.

    Any help would be greatly appreciated.

    TIA

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Cache OK for http; not writable for https Link to this post

    I suggest you do the following:

    1. Create a folder called silverstripe-cache into where you installed SilverStripe
    2. Give the newly created folder web user write permissions (chown www-data silverstripe-cache for example)
    3. Give the assets folder web user write permissions and all files inside (chown www-data -R assets)

    All cached files SS generates for the site will now reside in silverstripe-cache instead of the system temp folder. This makes it easier to manage, and should fix your problem as it will use this folder consistently.

    Sean

  • PhilQ
    Avatar
    Community Member
    3 Posts

    Re: Cache OK for http; not writable for https Link to this post

    Thanks Sean!

    I'm working with John on this, and we did exactly that. It worked for the most part, but when we tried to upload a file in the Files & Images section (via https), it seemed to not want to heed our cache folder selection, and tried to read/write to the systems '/tmp' folder.

    I got an error on:

    move_uploaded_file(/tmp/php9FYg6S, /home/stripe/public_html/assets/Uploads/07130029.JPG)

    It looks to me like it is trying to access the /tmp folder, which I imagine is where PHP puts files that get uploaded via a standard file upload.

    We haven't run into this on other hosts, so we're not sure if this is a SilverStripe issue, or not. It seems to work (no error) when we're not in https. One thought we had was that the host might be running as a different user when in https mode. It may be using the /tmp folder when we're not in https, and simply be working.

    Do you know where I can override the /tmp directory for uploads? That might be a work-around that would get us where we need to be.

    Thanks!

    -Phil

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Cache OK for http; not writable for https Link to this post

    I think the problem you're having is that uploads don't use this folder because PHP uses it's system temporary folder for uploads.

    This also applies to where sessions are stored by PHP as well. We'll need to override these to use the SilverStripe defined temp path instead.

    Add these two lines to the top of mysite/_config.php:

    session_save_path(getTempFolder());
    ini_set('upload_tmp_dir', getTempFolder());

    Now it should be using the "silverstripe-cache" folder for session, uploads and SilverStripe caches! This keeps it tidier, because all of the temporary files are stored in the same place.

    Good luck!
    Sean

  • PhilQ
    Avatar
    Community Member
    3 Posts

    Re: Cache OK for http; not writable for https Link to this post

    Thanks Sean! That was a great idea.

    Unfortunately it didn't work.

    I tried adding that to mysite/_config.php like this:

    <?php

    global $project, $database;
    $project = 'mysite';
    $database = 'SS';

    require_once("conf/ConfigureFromEnv.php");

    session_save_path(getTempFolder());
    ini_set('upload_tmp_dir', getTempFolder());

    In our _ss_environment.php we are defining the cache dir as well.

    # Cache Dir
    define('TEMP_FOLDER', '/home/stripe/silverstripe-cache');

    I also tried adding your lines to our _ss_environment.php file, after we defined the TEMP_FOLDER, like this:

    <?php
    define('TEMP_FOLDER', '/home/stripe/silverstripe-cache');
    session_save_path(TEMP_FOLDER);
    ini_set('upload_tmp_dir', TEMP_FOLDER);

    No love.

    The error I am seeing is:

    [Warning] Unknown: open(/tmp/silverstripe-cache-home-stripe-public_html/sess_58f46e4a101d50f45488dd4831bc6512, O_RDWR) failed: Permission denied (13)

    Seems not to be heeding our instructions.

    Again, this only happens when we are using https. It all works fine for http.

    Any other thoughts?

    Thanks for your help so far!!!

    -Phil

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Cache OK for http; not writable for https Link to this post

    The following is not necessary if silverstripe-cache exists in the project code (as Core.php works this out for you):

    define('TEMP_FOLDER', '/home/stripe/silverstripe-cache');

    It's a bit puzzling that you can't get the sessions to store elsewhere.

    Cheers,
    Sean

    1615 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.