LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-20-2019, 05:30 PM   #1
Janvanl
Member
 
Registered: Apr 2015
Posts: 145

Rep: Reputation: Disabled
symlinks with apache php, is there an alternative


Hi,

what i want is to point 4 subdirectories in 4 cms's to one physical directory with all images.

I tried using symlinks but the cms will not work with that.

Does someone have an idea on how to solve this?

regards,
Jan
 
Old 09-20-2019, 06:14 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Quote:
Originally Posted by Janvanl View Post
Hi,

what i want is to point 4 subdirectories in 4 cms's to one physical directory with all images.

I tried using symlinks but the cms will not work with that.

Does someone have an idea on how to solve this?

regards,
Jan
To be clear, does cms mean Content Management System? If not, what does it mean?

Are you sure that it's the CMS that doesn't work? It could be the apache configuration.
apache symlink usage can be tricky. For example, I've discovered that setting FollowSymLinks for a directory does not propagate to sub-directories. (I was ready to throw a 'puter out the window before I figured that out)
 
Old 09-20-2019, 06:36 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Janvanl View Post

what i want is to point 4 subdirectories in 4 cms's to one physical directory with all images.

I tried using symlinks but the cms will not work with that.
Hard to believe.
Quote:
Does someone have an idea on how to solve this?
Bind mounts are an alternative to symlinks.
 
Old 09-21-2019, 02:56 AM   #4
Janvanl
Member
 
Registered: Apr 2015
Posts: 145

Original Poster
Rep: Reputation: Disabled
Thanks for the replies,

cms means content management system, cms made simple a PHP cms.

I have put "Options +FollowSymLinks" and "Options + Indexes" in the htaccess.
Now I do not get an error on the "pwd" anymore that cannot be set, but I jump back to the
root-directory of the cms.

I am testing this on a local machine and with bash I can run ls on the symlink,
it shows all the files in the directory that I put the symlink on.

So it is an apache/php/cmsms problem I guess.

Regards,
Jan
 
Old 09-22-2019, 05:24 AM   #5
Janvanl
Member
 
Registered: Apr 2015
Posts: 145

Original Poster
Rep: Reputation: Disabled
Hi,

I used mount --bind and with only one subdirectory that works.

Just what I want is to have a bunch of files (images) in ONE subdirectory and
link this directory to 4 different subdirectories from 4 CMSses so these 4 CMSses
can use the same pool of images.

I looked at "mount --make-shared mountpoint" but it seems to work the other way around.

I consider using rsync and have copies of the images in all subdirectories, but hope
there is a way to avoid that.

regards,
Jan
 
Old 09-22-2019, 05:36 AM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Quote:
Originally Posted by Janvanl View Post
I have put "Options +FollowSymLinks" and "Options + Indexes" in the htaccess.
Now I do not get an error on the "pwd" anymore that cannot be set, but I jump back to the
root-directory of the cms.

I am testing this on a local machine and with bash I can run ls on the symlink,
it shows all the files in the directory that I put the symlink on.

So it is an apache/php/cmsms problem I guess.

Regards,
Jan
What do you mean by 'on the "pwd"'? How are you running pwd inside your php code?
What do you mean by "jump back to the root-directory..."

How are you defining the symlinks?
Show us the relevant section of your config/htaccess.
Show us the section of the php that's using the linked directory.

Once the symlink is set up, and +FollowSymLinks is set for the directory where the symlink is, the browser should just treat it like a real directory.
 
Old 09-22-2019, 06:29 AM   #7
Janvanl
Member
 
Registered: Apr 2015
Posts: 145

Original Poster
Rep: Reputation: Disabled
Thanks for the reply,

pwd - working directory, I got an error because the filemaneger inside CMSMS could not set the pwd (working directory)
pwd - print name of current/working directory (bash)

"jump back to the root-directory..."
I made a symlink to another directory outside the directory-tree for the CMS ln -s /var/www/ap ap
The CMS stores images in "[rootdir]/uploads/images" I made a subdirectory ap "..../uploads/images/ap" to which the symlink points.
On the commandline I can use "ls" and I get what I expected.
When I used the filemanager from the CMS and clicked the symlinked directory "ap", I jump to the "rootdirectory" of the CMS

defined the symlink
from directory /uploads/images
sudo -u www-data ln -s /var/www/ap ap

.htaccess just 2 lines because I test it on localhost
Options +FollowSymLinks
Options +Indexes

The PHP-Code of Filemanager of the CMS made with Smarty I will have to ask where to find it,
I am not the programmer.


regards,
Jan
 
Old 09-22-2019, 07:34 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Try to narrow it down - is apache causing this to not work, or something inside all 4 CMS's (the latter seems unlikely)?
Do some testing without any CMS first - does the server serve symlinked directories at all?

And show us. Output, commands, logs...
 
Old 09-22-2019, 07:46 AM   #9
Janvanl
Member
 
Registered: Apr 2015
Posts: 145

Original Poster
Rep: Reputation: Disabled
Hi ondoho

the CMS is CMS Made Simple. I am testing local - the filemanager is the same.
So if CMSMS cannot handle symlinks it will not work for all of them.

The idea to test without CMSMS is good, I will do that now.

Be right back again.

regards,
Jan
 
Old 09-22-2019, 08:13 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by Janvanl View Post
I am testing local - the filemanager is the same.
I don't understand this sentence.
Also CMSMS is only one - of four?
 
Old 09-22-2019, 08:14 AM   #11
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Janvanl View Post
So if CMSMS cannot handle symlinks it will not work for all of them.
Check too if the file or directory linked TO is within the apache "chroot" tree (often /var/www/htdocs) as apache cannot see ANY directories above it (or otherwise not below that directory).
 
Old 09-22-2019, 09:06 AM   #12
Janvanl
Member
 
Registered: Apr 2015
Posts: 145

Original Poster
Rep: Reputation: Disabled
OK
the symlink will not work without CMSMS either,

Thanks ehartman, I am trying this all within 1 Apache-install, all below var/www,
linked is to a subdirectory 2 levels below the sites root.

I will do this again on a test-install on the server where it should come because
if it works there then the problem is solved.

regards,
Jan
 
Old 09-22-2019, 09:24 AM   #13
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
I'm going to ask this again, because you didn't answer specifically.
Is the +FollowSymLinks for the directory where the link is? That is:
Code:
<Directory /var/www/>
    Options +FollowSymLinks
    Options +Indexes
</Directory>
And /var/www/ap looks like
Code:
lrwxrwxrwx.  1 someuser somegrp        27 Apr 29 12:04 /var/www/ap -> /path/to/otherdir/
Again, Option +FollowSymLinks is specific to the directory for which it is defined. It does not propagate to sub directories as some other Options do.

PS Options can be specified on one line...
Code:
Options +FollowSymLinks +Indexes
 
Old 09-22-2019, 09:32 AM   #14
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,760

Rep: Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224Reputation: 2224
Quote:
Originally Posted by ehartman View Post
Check too if the file or directory linked TO is within the apache "chroot" tree (often /var/www/htdocs) as apache cannot see ANY directories above it (or otherwise not below that directory).
I note this in httpd.conf:
Code:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
(emphasis added)
So, a working symbolic link can point outside the DocumentRoot (apache "chroot") tree, but of course the symbolic link itself must be within the DocumentRoot tree. (unless Aliased...but let's not go there today)
 
Old 09-22-2019, 09:32 AM   #15
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Janvanl View Post
nks ehartman, I am trying this all within 1 Apache-install, all below var/www, linked is to a subdirectory 2 levels below the sites root.
Another observation: I do not know how strong the "chroot" in Apache is (never used this myself), but you might try to use relative, not absolute, paths for the links as "/" may not be the same for Apache as for the whole filesystem.
So if the directory you want to link TO is /var/www/htdocs/some/dir
and the link should be in the directory /var/www/htdocs/somewhere/else
create the link by using
Code:
cd /var/www/htdocs/somewhere/else
ln -s ../../some/dir <name of the link>
so that you never have a pathname with "/" as the starting directory.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there (do we need) a GUI/tui to create symlinks for the /etc/rc.d/rc?.d directories? Lockywolf Slackware 5 06-22-2018 07:23 AM
Is there any default numbering system for creating symlinks inside /etc/rc3.d/ krssarath Fedora 4 02-09-2013 02:38 PM
FC5 Apache can't display symlinks bricox Linux - General 6 11-22-2006 01:31 AM
Is there a xine plugin to play midis? Is there an alternative player for midis? drdroid Linux - Software 5 02-15-2004 12:33 PM
Apache Symlinks gdw Linux - Networking 1 02-27-2003 07:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration