Symlinks for plugin assets are not working reliable

At my local apache devkit and public staging server the symlinks to the plugin assets work. they are created and followed. but for my clients server (apache) they do not – 403 and error page. the htaccess file is identical.
Options +FollowSymlinks should be available. at least provider support says so.
using Options +SymLinksIfOwnerMatch instead does not help.

  • symlink is created with same user and group as all other files. 777permissions.
  • parent dir is executable as well

server
apache, php 7.2

Kirby Version
3.1.2

asset

Are you creating the symlinks with PHP, or by hand in the terminal directly on the server?

I’ve use symlinks to share stuff between projects, but i’ve only done it with folders, not individual files. Maybe try that?

Can you give a bit more detail about the use case? How do you deploy? Maybe that process is upsetting permissions somewhere. Have you checked the permissions of each part of the path?

the symlink is created by kirby. it calles php symlink as far as i can tell?

Try deleting it and doing by hand in terminal. Then you know somethings off with whatever PHP is doing to create it :slight_smile:

Or do you mean this is something Kirby is doing and should work, rather then something uve done?

its cheap shared hosting. i do not have access to the terminal. since it works in similar setup flawlessly i am suspecting a faulty/to-secure apache conf. i just need to find out what exactly.

Hmm…I was going say maybe do a shell exec with php and run the terminal command that way. I dont know what php symlink() does technically to create it. Probably just that. If its shared hosting, they’ve probably locked down php from executing commands like that.

the symlink (an parent dir) itself looks fine (user, group, permissions). even on the faulty host. it just causes a 403 instead of being followed.

Is the server running cPanel? Have look in it - sometimes there is a Terminal app inside it. I’ve seen it on some shared hosting, but its locked down to just that hosting folder. Might give you more info.

Do you have to use this cheap hosting? Maybe switch to fortrabbit. They give SSH access, even on the 5 Euro plan.

Have you tried Options -SymLinksIfOwnerMatch (instead of Options +SymLinksIfOwnerMatch)?

AFAIK these are directory directives, so it might be good to check if they are set for the right directory.

@jimbobrjames sadly i am limited to ftp. no chance for anything else. but i appreciate the ideas.

using - instead of + does not work either. but thanks.

:disappointed: Does it work in a simplified use case (only a php file without kirby or other abstractions)?

@bvdputte thanks for reminding me it could be proven by a simple test.

i created one but it fails as well. so i contacted provider support again and gave them hell (an invoice would have been better tough). :stuck_out_tongue_closed_eyes:

<?php

$root = realpath(__DIR__ . '/media');
$target =  $root . '/symlink_root/test.js';
$f = file_exists($target);
var_dump($f);

$link = $root . '/symlink_test/test.js';

$dir = dirname($link);
var_dump($dir);
mkdir($dir); // not recursive!

symlink($target, $link);
sleep(1);
$f = file_exists($link);
var_dump($f);

?>
<a href="<?= '/public/media/symlink_test/test.js' ?>">symlink_root/test.js // symlink_test/test.js</a>

I’m glad you found proof that it’s not your fault. But it’s always sour losing that precious time at stuff like this.

I hope they fix it soon :raised_hands:

1 Like