Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Apache does not serve some symlinked video files

Wed Aug 14, 2019 8:06 am

I have an RPi3 with apache2 serving a video website for my family's use.
The video files are inside the home dir (~/www/videos) in subdirectories depending on type.
I have symlinked the videos dir as sudo into /var/www so they can be accessed and served out by apache.
This works fine and I can edit the videos inside the home dir while serving from the document root below /var/www.

Today I wanted to make a collection of the latest videos available inside a new dir below videos (videos/latest).
So I created the latest dir and then symlinked a few videos into the latest dir as user pi (all inside home is done as pi).
The result is that the files are listed when accessing the latest dir in a web browser just like when entering the other dirs containing actual files.
But when I click the file the video does not start playing, instead the browser displays an error message:
No video with supported format and MIME type found.
If I do an ls-l inside the dir I get this:

Code: Select all

$ ls -l
total 8
lrwxrwxrwx 1 pi pi  57 Aug 14 09:14 2019-08-13_16PM_Deadline.mp4 -> 2019-08-13_16PM_Deadline.mp4
lrwxrwxrwx 1 pi pi  42 Aug 14 09:16 2019-08-13_17PM_MTP.mp4 -> 2019-08-13_17PM_MTP.mp4
-rw-rw-r-- 1 pi pi 157 Aug 14 09:21 index.php
-rw-rw-r-- 1 pi pi 157 Aug 14 09:20 video.php
The index.php renders the content in the dir by making a dir list showing only mp4 files each with a link to show the video through a call to video.php.

The page rendering in index.php works fine and a proper link is created for every found mp4 file.
But the link in the page does not work - it is of this form:

Code: Select all

https://video.xxxxxxx.com/latest/video.php?videofile=2019-08-13_17PM_MTP
and the video.php file will add .mp4 to the supplied argument videofile and serve it out.

I use the same php code in all directories and in those where the video file is a physical file it works fine but here it is a symlinked file and now it does not work when actually serving the file content.

Why is this so and what can I do to fix it?

EDIT:
Maybe it is not possible for files that are symlinked twice like these are? At least as seen from Apache's point of view.
But they do show up in file listings...
Bo Berglund
Sweden

epoch1970
Posts: 3875
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Apache does not serve some symlinked video files

Wed Aug 14, 2019 7:00 pm

The listing shows files are symlinked to themselves. Something went wrong when you created the links.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: Apache does not serve some symlinked video files

Wed Aug 14, 2019 8:15 pm

Yes, I did not use full paths in the ln command...
Relative paths are no good it seems like, after I changed the command to use full paths when creating the symlinks they are served out properly.

I have scripted the creation of these links now so I can run updates through cron nightly. Seems to work fine.

So I am OK now!
Bo Berglund
Sweden

Return to “Raspbian”