How to Setup Symlinks in Litespeed Apache

You can use symlink to put a website in under another website without having files actually in the same directory.

You can also use symlink to place framework like Laravel or Yii outside of public_html and prevent exposure of .env and still make it work for the main domain

    1. check in litespeed security settings that symlinks following is allowed
      1. make sure no other vhost settings that prohibit symlink
    2. make the destination folder ready
    3. identify the location where you will be making the symlink
      1. if symlink is a folder, don’t make that as a folder
    4. run this for the folder that holds the target symlink and the source symlink. The reason is, we need to know who the owner is for both, if they are different we need to set them the same
      ls -al
    5. if they are different, change the source to have same user as the target. I prefer to change the source rather than the target.
      chgrp {{user}} {{folder}}
    6. Now set the symlink. Note – do NOT add / even if you are trying to link folder. Make sure the target folder is not created.
      ln -s {{source}} {{target}}
      ln -s /home/username/a /home/username/public_html/somefolder

      This is an example of using symlink to place laravel out of public_html and still work. Just need to install laravel in app-root (you have to mkdir create the directory)

      ln -s /home/username/app-root/public /home/username/public_html

      This is an example of using symlink to place yii out of public_html and still work. Just need to install yii in app-root (you have to mkdir create the directory)

      ln -s /home/username/app-root/web /home/username/public_html
    7. You can now test

 

Some common problems:

[ERROR] [redacted] [HTAccess] Failed to open [redacted/.htaccess]: Permission denied
[INFO] [redacted] [redacted#Aredacted:443] File not found [redacted/403.shtml]
[INFO] [redacted] redacted#redacted:443] Auto Index is disabled for [redacted], access denied

This means the user is different, and Litespeed won’t allow reading. Check step 4,5 above

 

[Sun Nov ## ##:##:### 20xx] [core:crit] [pid ####] (13)Permission denied: [client [IP]:[PORT]] AH####: /home/[user]/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/[user]/public_html/' is executable

This means there is either a user mismatch (see above) error or the folder is not executable. Most likely your server require the symlink destination to be 755. Check if that is the case. If not sure, find out what a normal working folder’s CHMOD # is. Then apply same. Also check the files and subfolders all have proper permissions.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>