We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

linux simple linking between 2 folders

Medium Priority
546 Views
Last Modified: 2012-08-14
Hello experts

The goal is to create a simple link in Linux (I guess it is ln function):
I have a real folder on my server
/red5/videos

and I want to link it to /home/site/public_html/videos


so any file that is created into /red5/videos
will be acessible through /home/site/public_html/videos

ex: /red5/videos/file1.flv

will be accessible in :  /home/site/public_html/videos/file1.flv

As you guess  /home/site/public_html/videos/ is the path to Apache, so any video created in  /red5/videos/file1.flv will be accessible through the web

I need to link   it and not create a copy : everything is stored in /red5/videos/ but accessible through  /home/site/public_html/videos/

Regards
Comment
Watch Question

CERTIFIED EXPERT

Commented:

ln -s /red5/videos  /home/site/public_html/videos

ensure that /red5/videos have read and exec permission for the web server or all
CERTIFIED EXPERT

Commented:
#save the current contents of folder
mv /home/site/public_html/videos /home/site/public_html/videos.old
ln -s /red5/videos /home/site/public_html/videos

Link part is done.

Now I have to do the Apache part because I have to enable links in Apache.

What type of Linux is it?  What version?

Author

Commented:
using ln command will not make it accessible through apache ?

uname -r
2.6.9-78.0.5.ELsmp

cat /proc/version
Linux version 2.6.9-78.0.5.ELsmp (mockbuild@builder16.centos.org) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)) #1 SMP Wed Oct 8 07:12:03 EDT 2008

CERTIFIED EXPERT

Commented:
So you also need to allow Apache to allow symlinks

So in your httpd.conf file or apache.conf depending upon your type of Linux, have something like
<Directory /red5>
    Options FollowSymLinks
    AllowOverride None
</Directory>
as farzanj and stetor explained, you have two seperate tasks to perform:
1- creating symbolic link for your video directory under your web documents directory; this is performed by using ln -s linux command:
ln -s /red5/videos  /home/site/public_html/videos

2- This newly created directory is not a normal directory, it is a symbolic link and Apache will not allow it's users to see it's contets; so you have to configure Apache in a way that allows "Following Symbolic Links":
    Options FollowSymLinks
Dmitriy SkyIT Engeneer

Commented:
if symlink not work, you can use this:

mkdir /home/site/public_html/videos
mount --bind /red5/videos /home/site/public_html/videos



or ln -s /red5/videos /home/site/public_html/videos  (that peoples talking above), with FollowSymlinks into apache conf, (don't forget restart apache2 web server after)

also for not remount everytime when you reboot server, add

this:
mkdir /home/site/public_html/videos
mount --bind /red5/videos /home/site/public_html/videos


into /etc/rc.local file

before
exit 0
Dmitriy SkyIT Engeneer

Commented:
brr, without mkdir >_< of corse, you need mkdir only once, to create videos folder into your site folder ))
Dmitriy SkyIT Engeneer

Commented:
ah and don't forget  add permisions to read, and access, to all or add apache group to access (apache2 use "www-data" as group, and owner.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.