services.json failed to open stream: Permission denied in Laravel 4 - laravel

I was playing around with a working Laravel 4 installation and moved everything into a sub folder. Then I decided to not do that and I moved it all back (all via the command line):
mv * /folder
and then
cd folder
mv * ../
Now, the site is throwing the following error:
file_put_contents(/var/www/quantquote/app/storage/meta/services.json): failed to open stream: Permission denied
Here is a screenshot of the full error:
http://i.imgur.com/8deGG97.png
I've already tried setting permissions on the /storage folder to 777 to no avail.

Spent a whole day for solving this and this command simply solved my problem.
If your permissions are 777 for Laravel App folder and you still get this error, it's because SEliux has blocked it. You can easily unblock your application's folder using this command:
su -c "chcon -R -h -t httpd_sys_script_rw_t /usr/share/nginx/YOUR_LARAVEL_APP/"
That's it!
BTW never disable SElinux: http://stopdisablingselinux.com/

As I stated in my comment:
find app/storage -type d -exec chmod 777 {} \;
find app/storage -type f -exec chmod 777 {} \;
This will chmod all directories and files in app/storage to 777.

As the problem is related to permissions try re-giving the right permissions to app/storage and all its sub-directories and file.
You can do so from the root path of your Laravel app typing:
chmod -Rvc 777 app/storage
If for some reason this doesn't work, try:
find app/storage -type d -exec chmod -vc 777 {} \;
find app/storage -type f -exec chmod -vc 777 {} \;

When chmod 777 or chmod 775 fails check that subdirectories really exists:
app/storage/
├── cache
├── logs
├── meta
├── sessions
└── views
in case these folders does not exists you must to create it:
cd app/storage/
mkdir meta logs cache sessions views
cd ../
find storage -type d -exec chmod 775 {} \;
find storage -type f -exec chmod 664 {} \;
UPDATE 2016 for laravel 5+
In a default Laravel 5+ application structure, storage is at the same level than app. So the previous command becomes:
cd storage/
mkdir meta logs cache sessions views
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
https://laravel.com/docs/5.0/structure

If you're using CentOS7, follows these steps:
Change app/storage directory ownership
chown apache:apache app/storage
Change app/storage permissions
chmod -R 775 app/storage
Prevent SELinux from blocking the app/storage directory
su -c "chcon -R -h -t httpd_sys_script_rw_t [fullpath]/app/storage"

just type this on terminal:
php artisan cache:clear

Never run a 777, in recursive mode. It's a security issue.
For now, remove the services.json file, and try this :
Laravel 4: Failed to open stream: Permission denied

Try these commands one by one:
setenforce 0
setsebool -P httpd_can_network_connect_db on

Related

Error 500 in fresh magento 2.4.2 installation

I am making a new fresh install and i get error 500
I am running a magento 2.4.2 with php 7.416 and apache
Memory limit is at 2048M
I have runned the following commands
find . -type f -exec chmod 644 {} \; // 644 permission for files
find . -type d -exec chmod 755 {} \; // 755 permission for directory
find ./var -type d -exec chmod 777 {} \; // 777 permission for var folder
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
But i still get error 500.
Can someone please help me?
The reason for 500 is basically the web server has no permissions to load the pages from the installed magento directory. I personally faced the same issue while I was installing magento2 and it was really frustrating to see this after spending long hours at installation.
A quick fix is to add the Magento file system owner to the web server group and re-login to the user account or run bash if you are on ubuntu.
sudo usermod -a -G www-data <user name>
For a hassle free and straight forward installation help, refer to the blog where I clearly explained the requirements and steps for 2.4.2

Set permission to user and folder - laravel 5.1

Today with GIT I update my app but after that I got Internal Server Error.
I try to solve problem with command:
sudo chown -R ireserve:ireserve /home/ireserve/public_html
and
chgrp ireserve -R /home/ireserve/public_html
but again the same error:
here is my folder permissions:
Any idea what is a problem and how to solve?
I also try this commands:
find public_html/ -type d -exec chmod 755 {} \;
find public_html/ -type d -exec chmod ug+s {} \;
find public_html/ -type f -exec chmod 644 {} \;
chown -R ireserve:ireserve public_html
chown -R ireserve:ireserve public_html
chmod -R 777 public_html/storage
chmod -R 777 public_html/bootstrap/cache/

Warning: Your Magento folder does not have sufficient write permissions

I am new to Magento, I am trying to install a theme via magento connect manager, I copy and paste the extension key then click install and then proceed.I get error 'Warning: Your Magento folder does not have sufficient write permissions.'
please give some solution .Any help would be highly appreciated.
go to Magento home directory and just give permissions for your webroot.
e.g. (in ubuntu) : sudo chown -R www-data .
You could also change the permissions
chmod 777 -R downloader/*
I hope it helps.
[EDIT]
How about in your magento directory (use sudo for below commands if required.):
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
For the normal operation or installation of a Magento store, only 2 folders need to be writable:
/media - for web accessible files, such as product images
/var - for temporary (cache, session) and import/export files
Source here
To reset file permissions run:
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
chmod 777 -R downloader var media
In my case this wasn't enough. I had to set 777 permision also to parent folder - public_html (NOT recursive).
Here is a complete shell script that I wrote to help you setup permissions/ownership of your Magento Installation : mage-set-perms
The shell script is based on the recommendation of Magento official article found here
With me works with this reset permissions:
chmod -R 777 media/
chmod -R 755 var/
I follow some instructions in this url:
http://www.magentocommerce.com/wiki/groups/227/resetting_file_permissions
I used the other solutions listed, e.g.:
cd /var/www/html
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
chmod -R 777 downloader var media
But I also had to do:
chown apache:apache /var/www/html
Since the web root directory was still owned by 'root:root' and causing problems (by continuing to display the Magento error message).
Of all of these what worked was
public_html# find . -type d -exec chmod 775 {} \;
and
chgrp -R www-data
This returns the ability to use Local file system as opposed to FTP
755 does not have group create and delete permissions so 775 worked
Return /media and /var permissions back to /public_html/media# find . -type d -exec chmod 777 {} \;
/public_html/var# find . -type d -exec chmod 777 {} \;

using mamp to reindex magento indexer

I m trying to reindex my url rewrites for magento on local machine. I use Mac so i got terminal. when i run
/Applications/MAMP/htdocs/..../shell/indexer.php: Permission denied
it says permission denied.
indexer.php is not a shell script (or have shebang line). You must run it using PHP:
<path to php>/php <magento root>/shell/indexer.php
do a
sudo chmod -R 777 /path/to/magento
in your terminal only for testing on your localhost!!!
In your live environment do this
find top/directory -type f -exec chmod 0644 '{}' \;
find top/directory -type d -exec chmod 0755 '{}' \;

Your Magento folder does not have sufficient write permissions

I’m trying to set-up Magento on my server, but I still haven’t succeeded in installing plugins. When I go to the /downloader/ folder, I get the message:
Warning: Your Magento folder does not have sufficient write permissions.
If you wish to proceed downloading Magento packages online, please set all Magento folders to have writable permission for the web server user (example: apache) or set up FTP Connection on the Magento Connect Manager Settings tab.
```
I have recursively changed the permissions of all the files and folders via FTP and set them to 777, but that didn’t work. Then I asked my webhoster to chmod everything as well, but still it throws the same error. When I look at the project in FTP, I see that all files and folders are correctly set-up to 777.
Why do I still get this message and what can I do?
In this particular case I’m trying to install the LightSpeed eCommerce Connector (http://www.magentocommerce.com/magento-connect/lightspeed-ecommerce-connector.html). Is there some other way I can install this plugin without the Magento connector?
Hmm, figured it out. The webroot itself must also have write permissions. I don't know why and frankly I find that ridiculous, but it's working.
From the httpdocs or public_html folder in your webserver,
while logged in via SSH, try this:
chown -R apache:apache ./*
find ./ -type d -exec chmod 755 '{}' ';'
find ./ -type f -exec chmod 644 '{}' ';'
chown apache:apache ./
chmod 755 ./
We also need to provide sufficient permission to the var and media folder to make the site works correctly.
Below are the permission commands we can use to run Magento and provide permission through SSH.
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./media -type d -exec chmod 777 {} \;

Resources