Using Apache Alias to play videos outside web root directory

Recently, I encountered an issue that videos from external drive must be played or accessible to web server. This is the first time that I’ve heard about this problem but, I already said that I think it is possible. I just need to do some research about this. I saw Apache Alias and it seems that it might be the answer so I dig a little deeper and was able to use it to solve this issue.

Here is a sample scenario:

1. Videos are saved outside web directories. Example: /home/user/Videos

2. Videos needs to be accessed through http://hostname/videos

Here are the things I made to address the above issues:

  • Edited /opt/lampp/etc/httpd.conf by adding the following at the end of the file. httpd.conf location might be different if you are using other web server and OS.
    Alias /videos "/home/user/Videos" 
    <Directory "/home/user/Videos">
       Options Indexes FollowSymLinks MultiViews
       AllowOverride None
       Order allow,deny
       Allow from all
       Require all granted
    </Directory>
    
  • Run the following command to create symbolic link
ln -s /home/user/Videos /opt/lampp/htdocs/videos
  • Run the following command to add access rights to other users like the www-data.
sudo chmod o+x /opt/lampp/htdocs/videos -R
sudo chmod o+x /home/user/Videos -R
 That’s it. You can now access your videos /home/user/Videos using http://hostname/videos.

 

jundy

R&D Supervisor && Traveller && Nature Lover

More Posts - Website

Follow Me:
TwitterFacebookGoogle PlusYouTube

Leave a Reply

Your email address will not be published. Required fields are marked *


*