I have problem installing this package through Composer:
composer require laracasts/generators --dev
I get exception:
[ErrorException]
ZipArchive::extractTo(): Permission denied
Any idea?
I also tried:
composer clear-cache
It didn't help.
Edit:
$ ls -l storage
total 4
drwxrwxrwx+ 1 Sasa i Sandra None 0 May 16 12:36 app
drwxrwxrwx+ 1 Sasa i Sandra None 0 May 16 12:36 framework
drwxrwxrwx+ 1 Sasa i Sandra None 0 May 19 12:12 logs
I'm a Laravel noob and it took me a few good painstakingly hours to figure this one out. It is my understanding that you'll need to run the installer for your new project with laravel new <project> in a directory with write permission. Here's how I've done it:
### make directory and grant full permissions
sudo mkdir /var/www/laravel
sudo chmod -R 777 /var/www/laravel/
cd /var/www/laravel/
### run laravel installer
laravel new my-site
### move your project in www root
sudo mv my-site /var/www/
Moving the directory to /var/www/ is optional and you can leave it there or move it to anywhere your need it to be.
Related
I just updated ubuntu packages and composer update from inside my ssh terminal on Forge
Now when I try to login I get TokenMismatchException in VerifyCsrfToken.php (line 68)
I have tried
deleted browsers cookies and application data
php artisan clear:cache
composer dump-autoload
Deleted composer.lock on both sides, updated from homestead and git push to server
php artisan clear-compiled
Restarted Nginx, Server
I am running out of ideas now. What can I do to fix this??
Thanks
After discussion, it was a folder permissions issues.
chmod 777 -R storage
OP must be careful with this as it opens up the server.
More appropriate for production would be the following:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
chmod 777 -R storage was enough to enable log in, but it brought other issues. Users could not post images for example.
This is eventually what worked for me -
ssh
Check if forge is set as the user $ ps -aux | grep "php"
if you get www-data instead of forge, you might have the same problem as me and need to set forge as the user instead of www-data
$ sudo chown -R forge:www-data /home/forge/mysite.com
$ sudo chmod -R 770 /home/forge/mysite.com
Everything works as expected for me again
Back to pretending like I know what I'm doing!! :D
I've just git clone a repository of mine containing a Laravel 5.1 project. I've gone through the normal steps to get it up and running (setup the webserver, db, etc). I've now gone to the web address I configured and i'm getting the following error message:
ErrorException in compiled.php line 6648:
file_put_contents(/3c7922efc24ab13620cd0f35b1fdaa61): failed to open stream: Permission denied
Any idea's what folder it's trying to access?
I solved the problem with this solution, clarifying that if you have Windows, you apply lines 1 and 3 and it works the same.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
To solve this problem I needed to create a few folder's that were missing from my install. You require the following folders to be readable and writable by your www user:
/storage
/storage/cache
/storage/framework
/storage/framework/sessions
/storage/framework/views
/storage/framework/cache
/storage/logs
Also, set the folder permissions to 775. From the root directory run the command: sudo chmod -R 755 storage
If nothing help you and if you work on windows with docker it can be the issue that wrong symlink you have, you can try:
ln -s /var/www/storage/app/public /var/www/public/storage
And after that:
chown -R $USER:www-data storage
chmod -R 777 storage
on docker bash.
If you're using ubuntu, most likely you have to give permissions to that folder storage
cd into the project and
use the command -> sudo chmod 755 storage/*
I had similar problem in my localhost and the problem was that I was trying to upload a file larger than upload_max_filesize in my php.ini file .
just updating this to greater value and restart my server solved the problem ,, if you having similar problem this might be the case
If you are on a Linux distribution with SELinux enabled, here is what you need to do:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/my-app/storage
sudo chown -R nginx /var/www/html/my-app/storage
sudo chmod -R u+w /var/www/html/my-app/storage
This should set the proper context for the storage directory, allowing the web server to write to it.
I had this problem lately with my tests, and resolved it through: composer dump-autoload
This is how I solve a similar issue since I don't have access to the terminal to run sudo chown -R www-data:www-data /thedirectory
in
config/filesystem.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Then in my uploader controller
use Illuminate\Support\Facades\Storage;
$file_path= Storage::path('public/importable');
if (!is_dir($file_path)) {mkdir( $file_path,0775, true);}
This is a permission issue. I used few hours to resolve this problem. I found only 3 lines to give permissions. So first go to root folder f your Laravel application and run these 3 lines.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
For me it was because the single file was owned by root...written at some point when I setup the files, and the app couldn't read it. Solution could be to change ownership, get rid of it, etc.
For me solution was to change folder owner of laravel project. Ensure that is your own user and not root:www-data.
sudo chown -R username:group directory
Run the following command in the directory that is being triggered to check the permissions:
ls -lah
Then if there was any issue you can correct it with:
sudo chown -R username:group directory
I have a project in laravel 5 in my notebook (windows), I created a repository for it in bitbucket and decided to use on my desktop (ubuntu 14). But for some reason they are showing several errors. And I'm new in version 5, I searched but could not understand the reason for the errors.
My .gitignore:
vendor/
node_modules/
# Laravel 4 specific
bootstrap/compiled.php
app/storage/
# Laravel 5 & Lumen specific
bootstrap/cache/
storage/
.env.*.php
.env.php
.env
# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/
After cloning a repository within the htdocs of xampp, I used the following commands:
1) composer install
2) chmod 777 -R storage
3) chmod 777 -R bootstrap
but when opening http://localhost/myProject/public/
Whoops, looks like something went wrong.
1/1 ErrorException in Filesystem.php line 75:
file_put_contents(/opt/lampp/htdocs/myProject/storage/framework/services.json):
failed to open stream: No such file or directory
Run the commands the correct way:
chmod -R 777 storage
chmod -R 777 bootstrap
i.e. the -R flag needs to come after chmod.
To stop you from the start, there is NO permission issue. /storage is recursively chmodded 777 and whole project folder is chowned by apache:apache
I even renamed the log file to ...-old and apache created a new one... if it didn't have actual write permissions it would not had been allowed to create it.
Running under CentOS release 6.6 (Final)
Deployed the project from git, the homestead works for my colleague.
Full error:
[Mon May 18 10:17:58 2015] [error] [client 86.124.208.14] PHP Fatal
error: Uncaught exception 'UnexpectedValueException' with message
'The stream or file
"/var/www/vhosts/mapper.pavementlayers.com/storage/logs/laravel-2015-05-18.log"
could not be opened: failed to open stream: Permission denied' in
/var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84\nStack
trace:\n#0
/var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88):
Monolog\Handler\StreamHandler->write(Array)\n#1
/var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37):
Monolog\Handler\RotatingFileHandler->write(Array)\n#2
/var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Logger.php(265):
Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#3
/var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Logger.php(543):
Monolog\Logger->addRecord(400, 'exception 'Symf...', Array)\n#4
/var/www/vhosts/mapper.pavementl in
/var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
on line 84
It could be that SElinux is preventing Apache from creating this file.
To test this you could disable SElinux temporally with the following command:
setenforce 0
This will place SElinux in permissive mode. This means that you still receive an error message in your SElinux log file but SElinux will not block the command.
To activate SElinux again you can type:
setenforce 1
Or reboot your CentOS server.
Unfortunately, I had also problems with Laravel 5 on CentOS and the cause was SElinux.
I ended up with disabling SElinux. I know it is not the right thing to do but I haven't had time to get the two working together yet!
Update
So I finally had sometime to investigate this further and I got SELinux working together with Laravel 5. I have just updated this post for people that might run into this issue cause. Disabling SELinux is not the best strategy as mentioned above.
Three things need to be done:
The folders Storage and Bootstrap/Cache need to have the right SELinux context. This can be achieved via the following commands:
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/<Laravel Site>/storage(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/<Laravel Site>/bootstrap/cache(/.*)?"
The SELinux context needs to be applied on the directories:
restorecon -Rv "/var/www/<Laravel Site>/storage"
restorecon -Rv "/var/www/<Laravel Site>/bootstrap/cache"
The Apache user needs to have the rights to create files in both directories. This can be achieved via a ACL in CentOS 7:
setfacl -R -m u:apache:rwX storage/
setfacl -R -m u:apache:rwX bootstrap/cache/
The last thing you need to do is to enable SELinux again.
Try those commands for laravel 5
$ php artisan cache:clear
$ sudo chmod -R 777 app/storage
$ composer.phar dump-autoload
This happens because laravel do not have the permissions to write to the log file, at least for my case.
This worked for me, Laravel 5.4 and above
$ sudo chmod -R 755 storage/
$ sudo chown -R www-data storage/
$ sudo chgrp -R www-data storage/
$ php artisan cache:clear
$ php artisan config:cache
$ composer dumpautoload
Not all steps necessary.
You have to make sure the storage folder exists. If you're deploying from git, make sure the storage folder itself is tracked and created automatically.
ON Laravel 5.7
$ cd /var/www/html/
$ php artisan cache:clear
Application cache cleared!
for centos 7
# ausearch -c 'httpd' --raw | audit2allow -M my-httpd
# semodule -i my-httpd.pp
Since laravel.log is in the storage folder, so I will suggest you run this command on your terminal on Mac.
chmod -Rf 0777 storage
I install Symfony and do:
chmod -R 777 app/cache app/log
Open from browser - all works great! When go to console and do:
php app/console cache:clear
and get error what i have not primission to delete file. Ok, i l'll do it with sudo:
sudo php app/console cache:clear
Great! But...
In browser i get:
RuntimeException: Failed to write cache file
Please
Probably you should do 2 things:
Make sure that you are running you web-server from the same user as you are.
Change owner or permission to the directory, in which your project is stored.
I'll explain point 2 little deeply.
Usually you create projects in /var/www folder. So, sudo chmod -R 755 /var/www would fix your issue.
P.S. Next time you should provide more details on your configuration setup. At least, some ls -l and pwd would help us to give you proper answer faster.
Cheers ;)