Cannot save symbolic link on Elgg 2.3.16

I linked /home/username/web/myweb.com/public_html/myweb/cache/ to /home/username/web/myweb.com/private/data_folder/views_simplecache/

In my FFT app (WinSCP) I see the folder views_simplecache  with the link symbol in /home/username/web/myweb.com/public_html/myweb/cache. When I click it (in the FFT app) it takes my to /home/username/web/myweb.com/private/data_folder/views_simplecache/. So, I assume the symlink works fine.

However, when I check Use symbolic link to simple cache directory in Advanced Settings and save I get an error: Due to your server configuration the symbolic link can not be established automatically. Please refer to the documentation and establish the symbolic link manually.

How to fix?

Thank you

  • If the link exists and the webserver can access it, Elgg should automatically use it without the need to enable the "Use symbolic link" option (or rather you can't toggle it anyway).

    It might be that the webserver can't properly access the link / follow it if the owner of the link is not the same as the owner of the target directory. It's a bit tricky. See

    http://learn.elgg.org/en/stable/admin/performance.html#simplecache

    about using chown -h to change the owner of the link (not the owner of the target of the link!). It would be necessary to have shell access on the server to use this command. If it still doesn't work, it might be that the webserver is not following the link because not every directory within the path to the target directory belongs to the webserver (I have this problem only on my test server probably because Apache uses an alias for the install directory; in this case I created a second symbolic link in the root folder that points to the folder where the data diretory is located - not that I even use the cache link right now on the test sites anyway).

  • Thank you iionly,

    I created the link through

    ln -s /home/user/web/example.com/private/data_folder/views_simplecache /home/user/web/example.com/public_html/web_root/cache

    As a result the "Use symbolic link to simple cache directory" was checked automatically, and I cannot toggle it. The site seems to be working properly. But when I "Flush the caches" all the content views_simplecache was deleted, the site was left without any design (CSS), and I cannot rebuild content in data_folder/views_simplecache as usual.

    When I delete the "web_root/cache" linked folder the site is back to normal.

    The user owns all the folders including the web_root/cache and and the data_folder/views_simplecache.

    Please advise.

    Thank you very much.

     

     

     

  • I seem to remember a bug in one of the caches that upon clearing the cache it simply removed the root folder (cache_path) and created a new directory. I believe it was Stash.

    This would break the symlink.

    I can't find it anymore to be sure. We fixed it (in 3.x) by moving the Stash caches into a subfolder of cache_path.

  • In my case the symlink is not broken. Before I click "Flush the caches" I see the content of views_simplecache there. When I flush the caches the content of views_simplecache is cleared and  the symlink folder (cache) is cleared as well. No folder is removed or created.

    The problem is that after flushing, all the web design (css) disappears and the system does not rebuild it as usual.

  • Does the cached files (CSS etc.) gets recreated if you visit other pages of your site after you flushed the cache? It might be that the admin dashboard page is not correctly fully rebuild after you flush the cache (might be an Elgg 2.x issue already fixed in newer versions of Elgg).

    The other reason might be what I already mentioned in my last post. The webserver does not run as the same user you are usually logged in on your server (I'm not taking here about the Elgg site user but the user account you use to administrate your webspace). The user account name of the webserver might be "www" or "apache" or something different depending on the webhoster, the OS used etc.. Now the webserver might be configured to follow symbolic links only if the links themselves are owned by the user account the webserver runs as (or the webserver might read files but not write anything at the target location of the link). That why I linked to the docs in the previous posting. There's the commands

    cd /path/to/wwwroot/
    chown -h wwwrun:www cache
    

    posted there. The "chown -h" command would make the webserver the owner of the symbolic link. For the command to work you would have to be logged in as root or you probably can't change the owner. Before useing the command you need to find out the user name and group name the webserver runs under. You should be able to find this out if you make a "ls -l" on some newly created file in the data directory that has been created by the webserver (on your new server).

  • Yes, it was the ownership issue. Now it works fine.

    Thank you iionly for your detailed response... and for your patience :)