Changing Location of Page/Media Content

I am trying to install grav to an AWS Elastic Beanstalk environment (which are ephemeral). I have already attached an EFS store to the environment on mount /efs, but I am a bit confused how to redirect all the media & pages data to be served from a folder on that mount instead (i.e. /efs/grav/pages).

I found on another forum post that this can be done in Streams and setup.php, however there is precious little info on those.

The end result I’d like to have is that the theme, plugins & grav core get installed via git, then the UI (and admin) reads and saves all its content from /efs/grav/pages instead of the default location now, which is /var/app/current/grav/pages.

Any help anyone can provide would be very much appreciated!!

I thought I was able to get it working, but this setup.php is giving me a create folder error from grav.

/**
 * Multisite setup for subsites accessible via sub-domains.
 */

use Grav\Common\Utils;

// Get subsite name from sub-domain
$environment = 'production';

return [
    'environment' => $environment,
    'streams' => [
        'schemes' => [
            'page' => [
                'type' => 'Stream',
                'force' => true,
                'paths' => [
                    '/efs/grav/pages'
                ]
            ],
            'backup' => [
                'type' => 'Stream',
                'force' => true,
                'paths' => [
                    '/efs/grav/backups'
                ]
            ],
        ]
    ]
];

Does anyone see where I’m going wrong?

Ok, I found the solution after a lot of trial and error. The fix below allows Grav to be installed and working on an ephemeral environment such as AWS’s Elastic Beanstalk. Hopefully this helps someone in the future that finds this thread through Google.

Step 1. Create an EFS store inside AWS.
Step 2. Attach EFS store to your environment… https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/instance-configuration/storage-efs-mountfilesystem.config
Step 3. Move contents of /user/pages to /efs/grav/pages
Step 4. CHMOD /efs/grav/pages to allow for creation of pages from the Grav admin UI
Step 5. Edit /user/config/streams.yaml to look like this (mine was blank):
schemes:
page:
type: Stream
paths:
- /efs/grav/pages
Step 6. Nothing else… it shoudl work.

1 Like