4

I'm trying to:

composer dump-autoload

On a Ubuntu 16.04 server.

I get the error:

 file_put_contents(/var/www/example.com/site/vendor/composer/autoload_namespaces.php): failed to open stream: Permission denied

I have:

  1. Change permission of storage dir to 755
  2. Made sure the www-data user has correct usage rights

I still get the error. Any ideas on a fix?

panthro
  • 22,779
  • 66
  • 183
  • 324
  • do you have installed `selinux`? or some auditory service? In my box I had the same problem, once I allowed http service with `setsebool -P httpd_unified 1 ` everything got ok – manix Oct 21 '16 at 22:13

2 Answers2

4

First of all After installing Laravel, you should change the permission of some specific directory. Use these commands.

// If your project's directory is owned by root then,
sudo chown -R <username> path_to_laravel_project_directory

// Then change these persmissions (from the root of the laravel project directory)
sudo chmod -R 777 storage/
sudo chmod -R 777 bootstrap/cache/

// At the end please generate your project key
php artisan key:generate

// Now you can use
sudo composer dump-autoload

I hope this works.

Saumya Rastogi
  • 13,159
  • 5
  • 42
  • 45
1

Try to set these permissions:

sudo chmod -R 755 bootstrap/cache/
sudo chmod -R 755 vendor/composer
sudo chmod -R 755 storage
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279