5

I'm trying to set-up a laravel cms system that already exists on a shared host. But when i setup my laravel project on this shared hosting directory i get the error
symlink() has been disabled for security reasons
I can't seem to find a proper explenation on how i can fix this in my situation. I only get this error the first time and when i refresh this error, it disappears. Error message

2
  • 2
    hosting issue. the function symlink() is disabled, that's why it cannot be called. You need to enable it via php.ini or use a proper host.
    – philipp
    Apr 23, 2018 at 12:07
  • how to enable it in php.ini
    – xaander1
    Dec 27, 2019 at 16:52

5 Answers 5

3

There are 2 options to solve this;

  1. Use any of the supported services for file storage i.e Amazon S3, Dropbox, FTP, Rackspace

  2. Follow the steps below; Create a folder in /public folder named /storage Move all folders from /storage/app/public/ to the folder you created /public/storage/ Open file config/filesystems.php and change the values as shown;

     'local'     => [
        'driver' => 'local',
        'root'   => public_path('storage'),
    ],
    
    'public'    => [
        'driver'     => 'local',
        'root'       => public_path('storage'),
        'url'        => env('APP_URL') . '/storage',
        'visibility' => 'public',
    ],
    

Now open file .env and change or create the values as shown below;

AVATAR_DIR=avatars
SIGNATURE_DIR=signatures
LOGOS_DIR=logos
MEDIA_DIR=media
2

in your project's public directory, manually create a storage folder.

this worked for me

1

You can create symlink for your desired directory by logging in to your server via SSH download Putty and then login to your server via putty by using your server credentials. You can use linux commands to create a symbolic link:

ln -s TARGET LINK_NAME

Where the -s makes it symbolic.

1
  • In my case the php code wasn't able to create symlink so i tried it using sssh
    – Haider Ali
    Apr 23, 2018 at 12:30
1

After a lot struggle this trick work for me at shared hosting server for Laravel project.

  1. Connect with terminal at server via SSH or directly from CPanel

  2. Run this command at your terminal

    ln -s /folder-path-with-name-to-be-linked /folder-paht-where-you-want-to-link-it

e.g in my case

ln -s /home/user-name/public_html/domain-folder-name/storage/app/public /home/user-name/public_html/domain-folder/public/

Note: You don't need to change in php.ini and .htaceess files. Reference Link: https://unix.stackexchange.com/questions/141436/too-many-levels-of-symbolic-links/141442#141442?newreg=14b52f3d6fcb454399a1a1a66e2170df

0

The problem could be that your hosting provider will not let you create the smlink.Have you checked if this is the case? One suggestion if so, is to write the files that you would have put in the symlink folder directly into the public area of the site so that a symlink is not required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.