Set permission to user and folder - laravel 5.1 - laravel

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/

Related

Magento: Access forbidden! You don't have permission to access the requested object

I am trying to install magento on my local machine but it will show access forbidden error
I have attach screen shot below
I am using ubantu.
How I can solve this issue?
As I said in the comment above it's an easy fix via SSH. Make sure you're in the root directory of your Magento installation, and then execute the following commands:
find ./ -type f | xargs chmod 644
find ./ -type d | xargs chmod 755
chmod -Rf 777 var
chmod -Rf 777 media
Clear your browser cache and reload the URL of your Magento instance. At this point you should be able to continue with the browser-based installation process and begin setting up your store.
Apply following permissions :
find . -type f -exec chmod 400 {} \;
find . -type d -exec chmod 500 {} \;
find var/ -type f -exec chmod 600 {} \;
find media/ -type f -exec chmod 600 {} \;
find var/ -type d -exec chmod 700 {} \;
find media/ -type d -exec chmod 700 {} \;
chmod 700 includes
chmod 600 includes/config.php

Change all files and folders permissions of a directory to 644/755

How would I change all files to 644 and all folders to 755 using chmod from the linux command prompt? (Terminal)
One approach could be using find:
for directories
find /desired_location -type d -print0 | xargs -0 chmod 0755
for files
find /desired_location -type f -print0 | xargs -0 chmod 0644
The easiest way is to do:
chmod -R u+rwX,go+rX,go-w /path/to/dir
which basically means:
to change file modes -Recursively by giving:
user: read, write and eXecute permissions,
group and other users: read and eXecute permissions, but not -write permission.
Please note that X will make a directory executable, but not a file, unless it's already searchable/executable.
+X - make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone.
Please check man chmod for more details.
See also: How to chmod all directories except files (recursively)? at SU
The shortest one I could come up with is:
chmod -R a=r,u+w,a+X /foo
which works on GNU/Linux, and I believe on Posix in general (from my reading of: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html).
What this does is:
Set file/directory to r__r__r__ (0444)
Add w for owner, to get rw_r__r__ (0644)
Set execute for all if a directory (0755 for dir, 0644 for file).
Importantly, the step 1 permission clears all execute bits, so step 3 only adds back execute bits for directories (never files). In addition, all three steps happen before a directory is recursed into (so this is not equivalent to e.g.
chmod -R a=r /foo
chmod -R u+w /foo
chmod -R a+X /foo
since the a=r removes x from directories, so then chmod can't recurse into them.)
On
https://help.directadmin.com/item.php?id=589 they write:
If you need a quick way to reset your public_html data to 755 for directories and 644 for files, then you can use something like this:
cd /home/user/domains/domain.com/public_html
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
I tested and ... it works!
Easiest for me to remember is two operations:
chmod -R 644 dirName
chmod -R +X dirName
The +X only affects directories.
This worked for me:
find /A -type d -exec chmod 0755 {} \;
find /A -type f -exec chmod 0644 {} \;
Do both in a single pass with:
find -type f ... -o -type d ...
As in, find type f OR type d, and do the first ... for files and the second ... for dirs. Specifically:
find -type f -exec chmod --changes 644 {} + -o -type d -exec chmod --changes 755 {} +
Leave off the --changes if you want it to work silently.
This can work too:
chmod -R 755 * // All files and folders to 755.
chmod -R 644 *.* // All files will be 644.

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

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

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 {} \;

What permissions are needed to run Magento?

The Magento documentation tells us to do this:
chmod -R o+w media var
chmod o+w app/etc
That gets us past the installer.
Next, I'd like to download a theme from Magento Connect. Unfortunately, that is throwing an error that seems to be permissions related.
Settings has not been loaded. Used default settings
Config file does not exists please save Settings
Warning: Your Magento folder does not have sufficient write permissions.
What permissions are needed to get past that?
I'm also seeing an error about the connection string.
Connection string is empty
While we are at it, what are the total set of permissions that must be set to make Magento fully functional (and secure)?
I realize Magento != Wordpress. It's so close to being as install-friendly as Wordpress. Just a little more!
I use the following script, and run it every now and then.
In the future, I'm going to add chown -R root.www-pub to the end of it, add all users that have to modify the code to a www-pub group, and set the umask to 0002. In the meantime, the below script works well.
#!/bin/bash
if [ ! -f ./app/etc/local.xml ]; then
echo "-- ERROR"
echo "-- This doesn't look like a Magento install. Please make sure"
echo "-- that you are running this from the Magento main doc root dir"
exit
fi
if [ `id -u` != 0 ]; then
echo "-- ERROR"
echo "-- This script should be run as root so that file ownership"
echo "-- changes can be set correctly"
exit
fi
find . -type f \-exec chmod 644 {} \;
find . -type d \-exec chmod 755 {} \;
find ./var -type d \-exec chmod 777 {} \;
find ./var -type f \-exec chmod 666 {} \;
find ./media -type d \-exec chmod 777 {} \;
find ./media -type f \-exec chmod 666 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
If you are on a development environment, this is the way to go:
chmod -R 777 /magento-directory/
Otherwise this should do:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
The first line will find folders and chmod them to 755. The second find files and chmod them to 644.
More from a Magento wiki article.
Below links work well for setting permission in Magento
Here is the permission we need to run for the Magento.
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 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
http://www.letsknowit.com/permissions-needed-to-run-Magento
Use The following commands to set permissions, as suggested by the official documentation :
find . -type f -exec chmod 400 {} \;
find . -type d -exec chmod 500 {} \;
find var/ -type f -exec chmod 600 {} \;
find media/ -type f -exec chmod 600 {} \;
find var/ -type d -exec chmod 700 {} \;
find media/ -type d -exec chmod 700 {} \;
chmod 700 includes
chmod 600 includes/config.php
I also wrote a complete shell script for automating those tasks : mage-set-perms
As a bonus the script is also gentle towards security and data integrity tools like tripwire and aide etc.

Resources