We are going to roll out an update to a large Kirby site and we’d like to provide our client with a private link to check all change before going live. Because the content and media folders are huge, I was asking myself, if it would be possible to reuse those folders from the production site.
I’ve read about custom folder setups, see Configuring Kirby | Kirby CMS, but I don’t fully understand the way how to set this up yet.
I was thinking about a parallel folder setup on the server – /www/production and /www/dev. How would I have to set up the development version to co-use the production folders for content and media?
Are they are on the same box? You could probably symlink the content folder from live to staging, but since the media folder is always in a state of flux, i think you should probably leave that alone.
You could also use rSync to transfer from one location to another directly which might take a while the first run but subsequent runs will be much quicker since only the changes get synced. You can do this by logging into the server via SSH and doing the sync from there. And since you are using your hosting providers super fast connection to do it, it should be really fast.
Other then that, yes, you are probably looking at a custom folder setup so that both sites read from the same place. I think you actually want four folders:
Linux has the really neat feature of being able to link a folder to a another location. The voodoo being is that as far as the operating system is concerned, that folder exisits where the sym link is, even tho its somewhere else entirely on the server. Its just a simple command. Google for “symbolic link”, and be sure of what you are doing first, but i repeat … this is the live content content folder so any changes made in dev will show up on live.
That sounds easier. How would I have to write that path though? I know __DIR__ but I need to go a folder up. Are relative notations valid? Like '../production/content'? Or is __DIR__ . '../production/content' possible?
First of all, thanks @texnixe for the path solution.
It took me a while to get the development version running because of this line the in the production .htaccess which was blocking content access:
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]
For now, I just uncommented the line but is there a way to keep the rule intact while allowing access from the development install?
Hm, I could only test this in my local environment and there I didn’t have to change anything .htaccess-wise. I always thought the rule only blocked accessing files in the content folder when trying to reach them via the browser, not programmatically on the same server. Long story short, I don’t have an answer at the moment.
A short summary how to setup things correctly. The goal is two have two parallel installs, one for production and another for development where the latter is co-using the content folder:
www/
∟ production/
∟ assets
∟ content
∟ kirby
∟ media
∟ site
∟ development/
∟ assets
∟ kirby
∟ media
∟ site
The only thing missing from development is the content folder.
The index.php will have to look like this: