Skip to content

Moving videos directory and securing files from direct access to the video source file

Daniel Neto edited this page Jul 21, 2023 · 21 revisions

This tutorial shows you how to enable Apache XSendFile to prevent your videos from being accessed by external or unauthorized users. It will also help you set up the symbolic link to allow you to move your videos to another location

Need help to configure it?

Get 1-hour support on our Services Site, we will do it for you

DIY

What we use for that:

  1. Ubuntu 16
  2. Apache XSendFile
  3. SecureVideosDirectory Plugin

What will you need

  1. Root Access to the server
  2. Admin user for YouPHPTube

Enable SecureVideosDirectory

This is necessary for secure files and configuration assistant

Install apache xsendfile

sudo apt-get install libapache2-mod-xsendfile && sudo a2enmod xsendfile

Configure your apache XSendFile

sudo nano /etc/apache2/apache2.conf

<Directory /var/www/html/YouPHPTube/>
    Options Indexes FollowSymLinks
    XSendFile on
    XSendFilePath /var/www/html/YouPHPTube/
    AllowOverride All
    Require all granted
    Order Allow,Deny
    Allow from All
</Directory>

Uncomment your .htaccess file

sudo nano /var/www/html/YouPHPTube/.htaccess

<IfModule mod_xsendfile.c>
    RewriteRule    ^videos/([A-Za-z0-9-_.]+)$ view/xsendfile.php?file=$1    [NC,L]
</IfModule>

Moving AVideo Videos Directory to Another Drive and Creating a Symbolic Link

This guide will walk you through the process of moving the AVideo videos directory to another drive and creating a symbolic link to ensure the videos are accessible from the new location. Please make sure to follow the steps carefully to avoid any potential issues.

Note: Before proceeding, ensure you have a complete backup of your AVideo installation and videos.

Steps to Move AVideo Videos Directory

Move Videos: Change to the AVideo videos directory and either move or copy the videos to the newly mounted drive:

cd /var/www/html/AVideo/
sudo mv ./videos /newMountedDisk/videos

Creating a Symbolic Link

To create a symbolic link to make the videos accessible from the original location, follow these steps:

Create the Symbolic Link: Create the symbolic link using the ln command:

sudo ln -s /newMountedDisk/videos /var/www/html/AVideo/videos

Now, the AVideo videos should be accessible both from the new location (/newMountedDisk/videos) and through the symbolic link (/var/www/html/AVideo/videos).

Verification

To ensure everything is working as expected, access your AVideo application and play some videos. Verify that the videos are loading and playing correctly from the new location and through the symbolic link.

Clone this wiki locally