Problems enabling symbolic link to cache - messes up the display

Here is what I am running

apache 2.2.27

php 5.6.30

elgg 2.3.3

running on a vps server.  One main site and one small site i use for testing. only other potential hog of resources running on the vps is red5 to dish up some video chat but is rarely used.

symlink located in the public_html folder with the following:

ln -s /home/sitename/data/views_simplecache/ cache 

owner of the symlink cache and data and views_simplecache are the same.  Permissions on the views_simplecache directory are 755.

Process used to enable it.  Disable all cache in elgg settings and save.  create the symlink.  enable the cache in elgg. run upgrade.php.  Have half a beer and wait just in case it takes some time for things to update and process.  I have tried disabling the theme and re-enabling it with the same result whether a theme is enabled or not.

What I am seeing is that the site works.. but graphics are not displaying properly.  As in it pretty much looks like a text site down the left hand side of the screen with no formatting.  The links do work and testing from another computer even with a clear local cache shows the same thing.  When I remove the symlink the site goes back to looking normal.

What I can see is that there are some files that have been created in the views_simplecache folder so it appears elgg is writing something out there.

I verified my .htaccess allows symlinks

# Follow symbolic links
Options +FollowSymLinks

The site is growing enough that it is starting to get kind of slow with the number of plugins we have on it so looking for ways to boost the performance.  Already have had to remove one because it caused almost a complete stop (river grouping 2.2.2)

Of possible concern is that server info shows that memcache is not set up on the server yet and will look at that too but figured enabling the symbolic link would be an "easy" step that has taken a lot more effort than expected.

So with that all being said... what is the trick to getting the symlink to work right?  I am out of ideas and tried to do my due diligence and research first before asking but am stuck on this one. 

  • You could try a

    chown -h wwwrun:www cache

    on the symlink. The ownership of links is a bit tricky. What you normally see is the owner/group of the file/directory the links refers to. But on Linux for example the link itself can also have a (possible different) owner/group. With the "-h" parameter on chown the change will affect the link and not the reference. You might need to adjust wwwrun:www depending on the owner and group your Apache server runs as. I also had to do the "chown -h" myself because Apache is quite strict on security with following symlinks (and I also had no idea why it failed to work for quite some time).

  • Thanks for your reply.. it makes some sense.  When tried the chown for wwwrun:www it comes back with an invalid user.  I am not quite sure how to find the correct name to use and so far haven't found a good reference on how to look it up.  Will be digging into google to see what I can track down but if someone has a simple solution would appreciate it.

  • One possibility to find out: with the "top" command you get a list of running processes. The Apache processes should be named "http" or "http-prefork". The listing includes the user of the process. Group of the process might not be enabled. But you can do that by pressing SHIFT-F and then enable group (you might also need to move the group up for better visibility in the process table).

    If top doesn't work you can google for the Apache user including the Linux distribution's name in the search (as user/group is mostly a matter of the Linux flavour used).

  • Interesting that the username and group name is nobody for httpd processes.  That from what I see is a pseudo name and not meant to own any files or folders:

    The nobody user is a pseudo user in many Unixes and Linux distributions. According to the Linux Standard Base, the nobody user and its group are an optional mnemonic user and group. That user is meant to represent the user with the least permissions on the system. In the best case that user and its group are not assigned to any file or directory (as owner). This user is in his corresponding group that is (according to LSB) also called "nobody" and in no other group.

  • Apache can be configured to run under a specified user and group. But the Apache config is a matter your webhoster is responsible for in the first place. On a VPS you will likely be able to adjust the Apache config on your own, if you want Apache to not run as nobody. Then you would likely also have to update all files and directory ownership accordingly or there might be permission issues. Then you could "chown -h" also the cache symlink accordingly. I can't give you any detailed help how to change the Apache config accordingly as it might be different regarding where to change it. Maybe in /etc/apache2/http.conf is some info in the comments with regard to the where the user and group is specified. For example it's done in /etc/apache2/uid.conf on my server.

    Or you could just do the "chown -h" on the symlink to nobody:nobody for testing. If it doesn't fix the issue, the problem needs to be fixed in some other way anyway. And if you don't want the ownership to stay as nobody:nobody you can just delete the symlink again.