I am new to Laravel. I was trying to open http://localhost/test/public/
and I got
我对拉腊威尔不熟。我尝试打开http://localhost/test/public/,得到
Error in exception handler.
错误的异常处理程序。
I googled around and changed the permission of storage directory using chmod -R 777 app/storage
but to no avail.
我用chmod -R 777 app/storage搜索并更改了存储目录的权限,但没有效果。
I changed debug=>true
in app.php
and visited the page and got Error in exception handler:
在app.php中,我将debug=>改为true,并访问页面,异常处理程序出现错误:
The stream or file "/var/www/html/test/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/test/bootstrap/compiled.php:8423
流或文件“/var/www/html/测试/应用程序/存储/日志/laravel”。无法打开日志:未能打开流:/var/www/html/test/bootstrap/compiled.php:8423中拒绝的权限
Then I changed the permissions of storage directory using the command chmod -R 644 app/storage
and the 'Error in exception handler' error was gone and a page is loaded. But in there I am getting this:
然后我使用命令chmod -R 644 app/storage更改了存储目录的权限,并删除了“异常处理程序中的错误”,加载了一个页面。但是在那里我得到了这个:
file_put_contents(/var/www/html/laravel/app/storage/meta/services.json): failed to open stream: Permission denied
file_put_contents(/var/www/html/laravel/app/storage/meta/services.json):未能打开流:权限被拒绝
29 个解决方案
#1
288
Suggestion from vsmoraes worked for me:
vsmoraes的建议对我起了作用:
Laravel >= 5.4
Laravel > = 5.4
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
Laravel < 5.4
Laravel < 5.4
php artisan cache:clear
chmod -R 777 app/storage
composer dump-autoload
#2
62
For googlers who has been facing this problem with Laravel 5.
对于谷歌人来说,Laravel 5一直面临着这个问题。
This is a permission issue caused by different users trying to write at the same log file within the storage/logs
folder with different permissions.
这是由于不同的用户试图在具有不同权限的存储/日志文件夹中写入相同的日志文件而导致的权限问题。
What happens is your laravel config probably is setup to log errors daily and therefore your webserver (apache/nginx) might create this file under a default user depending on your environment it can be something like _www
on OSX or www-data
on *NIX systems, then the issue comes when you might have run some artisan commands and got some errors, so the artisan will write this file but with a different user because PHP on terminal is executed by a different user actually your login user, you can check it out by running this command:
发生了什么是你laravel配置可能是设置每天记录错误,因此你的web服务器(apache / nginx)可能会创建这个文件默认用户根据您的环境下可以像_www www - data在* NIX系统中,在OSX或问题时,你可能会运行一些命令工匠和有一些错误,所以工匠将与一个不同的用户,因为写这个文件但PHP在终端实际上执行的是一个不同的用户登录用户,您可以通过运行以下命令来检查:
php -i | grep USER
If your login user created that log file your webserver you will not be able to write errors in it and vice-versa because laravel writes log files with 655
permissions by default which only allows the owner to write in it.
如果您的登录用户创建了您的web服务器的日志文件,那么您将无法在其中写入错误,反之亦然,因为laravel在默认情况下使用655权限编写日志文件,这只允许所有者在其中写入。
To fix this temporary you have to manually give permissions for the group 664
to this file so both your login user and webserver user can write to that log file.
要修复这个临时文件,您必须手动为这个文件授予组664的权限,以便您的登录用户和webserver用户都可以写入该日志文件。
To avoid this issue permanently you may want to setup a proper permissions when a new file is create within the storage/logs
dir by inheriting the permissions from the directory this answer https://unix.stackexchange.com/a/115632 can help you to tackle with that.
为了永久避免这个问题,您可能希望在存储/日志目录中创建新文件时,通过从目录中继承权限来设置适当的权限,这个答案https://unix.stackexchange.com/a/115632可以帮助您解决这个问题。
#3
40
For everyone using Laravel 5, Homestead and Mac try this:
对于每个使用Laravel 5的人来说,Homestead和Mac都可以试试这个:
mkdir storage/framework/views
#4
28
some times SELINUX caused this problem; you can disable selinux with this command.
有时SELINUX导致这个问题;您可以使用此命令禁用selinux。
sudo setenforce 0
#5
26
You should not give 777 permissions. It's a security risk. To Ubuntu users, in Laravel 5, I sugest to change owner for directory storage recursively:
您不应该授予777权限。这是一个安全风险。对于Ubuntu用户,在Laravel 5中,我建议递归地更改目录存储的所有者:
Try the follow:
试下:
sudo chown -R www-data:www-data storage
In Ubuntu based systems, www-data is apache user.
在基于Ubuntu的系统中,www-data是apache用户。
#6
19
Problem solved
问题解决了
php artisan cache:clear
sudo chmod -R 777 vendor storage
this enables the write permission to app , framework, logs Hope this will Help
这使写权限的应用,框架,日志希望这将会有所帮助
#7
14
For vagrant users, the solution is:
对于流浪用户,解决方案是:
(in vagrant) php artisan cache:clear
php artisan缓存:清除
(outside of vagrant) chmod -R 777 app/storage
(流浪在外)chmod - r777 app/storage
(in vagrant) composer dump-autoload
(流浪汉)作曲家dump-autoload
Making sure you chmod in your local environment and not inside vagrant is important here!
确保你在当地的环境中,而不是在流浪者内部是很重要的!
#8
10
Try again with chmod -R 755 /var/www/html/test/app/storage
. Use with sudo for Operation not permitted
in chmod. Use Check owner permission if still having the error.
再试试chmod -R 755 /var/www/ html/test/app/storageage。与sudo一起使用,用于chmod不允许的操作。如果仍然有错误,请使用Check owner权限。
#9
7
As per Laravel 5.4 which is the latest as I am writing this, if you have any problem like this, you ned to change the permission. DO NOT LISTEN TO ANYONE WHO TELLS YOU TO SET 777 FOR ANY DIRECTORY. It has a security issue. Change the permission of storage folder like this
根据Laravel 5.4,这是我写这篇文章的最新版本,如果你有任何类似的问题,你需要修改权限。不要听任何人告诉你为任何目录设置777。它有一个安全问题。像这样更改存储文件夹的权限
sudo chmod -R 775 storage
Change bootstrap folder permission like this
像这样更改引导文件夹权限
sudo chmod -R 775 bootstrap/cache
Now please make sure that you're executing both commands from your application directory. You won't face problems in future regarding permission. 775 doesn't compromise any security of your machine.
现在请确保您正在执行来自应用程序目录的两个命令。在未来你不会遇到关于许可的问题。775不会危及您的机器的任何安全性。
#10
6
If you have Laravel 5 and looking permanent solution , applicable both php artisan
command line usage and Apache server use this:
如果您有Laravel 5并正在寻找永久解决方案,那么可以使用php artisan命令行和Apache服务器:
sudo chmod -R 777 vendor storage
echo "umask 000" | sudo tee -a /etc/resolv.conf
sudo service apache2 restart
sudo chmod - r777供应商存储响应“umask 000”| sudo tee /etc/resolv重新启动conf sudo服务apache2
See detailed explanation here.
看到详细解释。
#11
6
Suggest the correct permission, if for Apache,
建议正确的权限,如果是Apache,
sudo chown -R apache:apache apppath/app/storage
#12
5
FOR ANYONE RUNNING AN OS WITH SELINUX: The correct way of allowing httpd to write to the laravel storage folder is:
对于任何使用SELINUX运行OS的人:允许httpd写入laravel存储文件夹的正确方法是:
sudo semanage fcontext -a -t httpd_sys_rw_content '/path/to/www/storage(/.*)?'
Then to apply the changes immediately:
然后立即应用这些变化:
sudo restorecon -F -r '/path/to/www/storage'
SELinux can be a pain to deal with, but if it's present then I'd STRONGLY ADVISE you learn it rather than bypassing it entirely.
SELinux可能是一个棘手的问题,但如果它存在,我强烈建议您学习它,而不是完全忽略它。
#13
4
I had the same issue and the below steps helped me fix the issue.
我遇到了同样的问题,下面的步骤帮助我解决了这个问题。
- Find out the apache user - created a test.php file in the public folder with the code
- 找到apache用户创建的测试。php文件在公共文件夹中的代码
<?php echo exec('whoami'); ?>
< ?php echo exec(“whoami”);? >
And run the file from the web browser. It would give the apache user. In my case, it is ec2-user as I was using the aws with cronjob installed in /etc/cron.d/. It could be different user for others.
并从web浏览器运行该文件。它会给apache用户。在我的例子中,它是ec -user,因为我正在使用安装在/etc/cron.d/中的aws。它可以是不同的用户。
- Run the below command on the command line.
- 在命令行上运行下面的命令。
sudo chown -R ec2-user:<usergroup> /app-path/public
sudo chown -R ec2-user:
You need to identify and use the right "user" and "usergroup" here.
您需要在这里标识并使用正确的“user”和“usergroup”。
#14
3
Xampp for use:
Xampp的使用:
cd /Applications/XAMPP/htdocs
chmod -R 775 test/app/storage
#15
3
NEVER GIVE IT PERMISSION 777!
go to the directory of the laravel project on your terminal and write:
转到您终端上的laravel项目目录,并写:
sudo chown -R your-user:www-data /path/to/your/laravel/project/
sudo find /same/path/ -type f -exec chmod 664 {} \;
sudo find /same/path/ -type d -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
This way you're making your user the owner and giving privileges:
1 Execute, 2 Write, 4 Read
1+2+4 = 7 means (rwx)
2+4 = 6 means (rw)
finally, for the storage access, ug+rwx means you're giving the user and group a 7
这样你就可以使你的用户成为所有者并给予特权:1执行,2写,4读1+2+4 = 7意味着(rwx) 2+4 = 6的意思(rw)最后,对于存储访问,ug+rwx意味着你给用户和组7。
#16
2
rm storage/logs/laravel.log
solved this for me
为我解决了这个
#17
2
If using laradock, try chown -R laradock:www-data ./storage
in your workspace container
如果使用laradock,请尝试chown -R laradock:www-data ./存储在工作区容器中
#18
1
Any time I change app.php I get a permission denied writing bootstrap/cache/services.json so I did this to fix it:
每当我修改app.php时,我都会得到一个拒绝写入引导/缓存/服务的权限。我这么做是为了修正json
chmod -R 777 bootstrap/cache/
#19
1
In my case solution was to change permission to app/storage/framework/views
and app/storage/logs
directories.
在我的案例中,解决方案是更改应用/存储/框架/视图以及应用/存储/日志目录的权限。
#20
0
If anyone else runs into a similar issue with fopen file permissions error, but is wise enough not to blindly chmod 777 here is my suggestion.
如果有人遇到类似的问题,fopen文件权限错误,但明智的做法是不要盲目地使用chmod 777。
Check the command you are using for permissions that apache needs:
检查您正在使用的命令,以获得apache所需的权限:
fopen('filepath/filename.pdf', 'r');
The 'r' means open for read only, and if you aren't editing the file, this is what you should have it set as. This means apache/www-data needs at least read permission on that file, which if the file is created through laravel it will have read permission already.
“r”的意思是为只读打开,如果你没有编辑文件,这就是你应该设置为的。这意味着apache/www-data至少需要在该文件上读取权限,如果文件是通过laravel创建的,那么它已经可以读取权限了。
If for any reason you have to write to the file:
如果由于任何原因你必须写到文件:
fopen('filepath/filename.pdf', 'r+');
Then make sure apache also has permissions to write to the file.
然后确保apache也具有写入文件的权限。
http://php.net/manual/en/function.fopen.php
http://php.net/manual/en/function.fopen.php
#21
#22
0
I have the same issue when running vagrant on mac. solved the problem by changing the user of Apache server in https.conf file:
我在mac上运行vagrant的时候也遇到了同样的问题,就是通过在https中改变Apache服务器的用户来解决这个问题。配置文件:
# check user for php
[vagrant] ubuntu ~ $ php -i | grep USER
USER => ubuntu
$_SERVER['USER'] => ubuntu
[vagrant] ubuntu ~ $
Run apache under php user instead of user daemon to resolve file access issue with php
使用php用户而不是用户守护进程运行apache来解决文件访问问题
# change default apache user from daemon to php user
sudo sed -i 's/User daemon/User ubuntu/g' /opt/lampp/etc/httpd.conf
sudo sed -i 's/Group daemon/Group ubuntu/g' /opt/lampp/etc/httpd.conf
now, php created cache file can be read and edit by apache without showing any access permission error.
现在,apache可以读取和编辑php创建的缓存文件,而不会显示任何访问权限错误。
#23
0
I had a similar problem. (Permission denied while the permissions where configured correct) with Laravel 5.2 and 5.5
我也有类似的问题。(权限被拒绝,而权限配置正确)使用Laravel 5.2和5.5
The problem was that SELinux was enabled which prevent Apache to write files even with 777 mode. See Solve 500 response Laravel (Uncaught UnexpectedValueException: Laravel.log) for the question and answer.
问题是启用了SELinux,使得Apache即使在使用777模式时也无法编写文件。关于问题和答案,请参阅解决500个响应Laravel(无意外值valueexception: Laravel.log)。
Maybe this solves the problem for you also.
也许这也能解决你的问题。
#24
0
After a lot of trial and error with directory permissions I ended up with an epiphany...there was no space left on the disk's partition. Just wanted to share to make sure nobody else is stupid enough to keep looking for the solution in the wrong direction.
在多次尝试和错误的目录权限之后,我终于顿悟了……磁盘分区上没有剩余空间。只是想分享,以确保没有其他人愚蠢到继续在错误的方向寻找解决方案。
In Linux you can use df -h
to check your disk size and free space.
在Linux中,可以使用df -h检查磁盘大小和空闲空间。
#25
0
Setting permission to 777 is definitely terrible idea!
将权限设置为777绝对是个糟糕的主意!
... but
…但
If you are getting permission error connected with "storage" folder that's what worked for me:
如果你得到的权限错误连接到“存储”文件夹,这对我是有效的:
1) Set "storage" and its subfolders permission to 777 with
1)将“存储”及其子文件夹权限设置为777。
sudo chmod -R 777 storage/
2) In browser go to laravel home page laravel/public/ (laravel will create necessary initial storage files)
2)在浏览器中浏览laravel主页laravel/public/ (laravel将创建必要的初始存储文件)
3) Return safe 775 permission to storage and its subfolders
3)将安全775权限返回到存储及其子文件夹
sudo chmod -R 775 storage/
#26
0
This issue actually caused by different users who wants to write/read
file but denied cause different ownership. maybe you as 'root' installed laravel before then you login into your site as 'laravel' user where 'laravel' the default ownership, so this is the actually real issue here. So when user 'laravel' want to read/write all file in disk as default, to be denied, cause that file has ownership by 'root'.
这个问题实际上是由想要写/读文件但被拒绝的不同用户引起的。也许你作为“root”安装了laravel,然后你作为“laravel”用户登录你的网站,“laravel”是默认的所有权,所以这才是真正的问题。因此,当用户“laravel”希望默认地读取/写入磁盘中的所有文件时,将被拒绝,因为该文件拥有“root”属性。
To solving this problem you can follow like this:
要解决这个问题,你可以这样做:
sudo chown -hR your-user-name /root /nameforlder
sudo chown -hR你的用户名/root /nameforlder
or in my case
或者在我的例子中
sudo chown -hR igmcoid /root /sublaravel
sudo chown -hR igmcoid /root /sublaravel。
Footnote:
补充说明:
-
root
as name first ownership who installed before - 作为之前安装的名称first ownership的根
-
your-user-name
as the default ownership who actually write/read in site. - 您的用户名作为实际在站点中编写/读取的默认所有权。
-
namefolder
as name folder that want you change the ownership. - namefolder作为名称文件夹,希望您更改所有权。
#27
0
I got same errors in my project...
But found out that I forgot to putenctype
in my form.我在项目中犯了同样的错误……但是我发现我忘记把enctype放在我的表格里了。
<form method="#" action="#" enctype="multipart/form-data">
Hopes it helps somewhere somehow...
希望它能在某个地方有所帮助……
#28
-2
For LARAVEL 5, try to create cache, sessions and views folders in storage/framework with 777 permission.
对于LARAVEL 5,尝试在存储/框架中创建具有777权限的缓存、会话和视图文件夹。
#29
-3
I have tried to give the 777
access to storage folder and it have work for me
我试图让777访问存储文件夹,它对我有帮助
1) go to your laravel root directory , (/var/www/html
for me) and run the following command
1)转到laravel根目录(/var/www/html for me)并运行以下命令
chmod 777 -R storage
#1
288
Suggestion from vsmoraes worked for me:
vsmoraes的建议对我起了作用:
Laravel >= 5.4
Laravel > = 5.4
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
Laravel < 5.4
Laravel < 5.4
php artisan cache:clear
chmod -R 777 app/storage
composer dump-autoload
#2
62
For googlers who has been facing this problem with Laravel 5.
对于谷歌人来说,Laravel 5一直面临着这个问题。
This is a permission issue caused by different users trying to write at the same log file within the storage/logs
folder with different permissions.
这是由于不同的用户试图在具有不同权限的存储/日志文件夹中写入相同的日志文件而导致的权限问题。
What happens is your laravel config probably is setup to log errors daily and therefore your webserver (apache/nginx) might create this file under a default user depending on your environment it can be something like _www
on OSX or www-data
on *NIX systems, then the issue comes when you might have run some artisan commands and got some errors, so the artisan will write this file but with a different user because PHP on terminal is executed by a different user actually your login user, you can check it out by running this command:
发生了什么是你laravel配置可能是设置每天记录错误,因此你的web服务器(apache / nginx)可能会创建这个文件默认用户根据您的环境下可以像_www www - data在* NIX系统中,在OSX或问题时,你可能会运行一些命令工匠和有一些错误,所以工匠将与一个不同的用户,因为写这个文件但PHP在终端实际上执行的是一个不同的用户登录用户,您可以通过运行以下命令来检查:
php -i | grep USER
If your login user created that log file your webserver you will not be able to write errors in it and vice-versa because laravel writes log files with 655
permissions by default which only allows the owner to write in it.
如果您的登录用户创建了您的web服务器的日志文件,那么您将无法在其中写入错误,反之亦然,因为laravel在默认情况下使用655权限编写日志文件,这只允许所有者在其中写入。
To fix this temporary you have to manually give permissions for the group 664
to this file so both your login user and webserver user can write to that log file.
要修复这个临时文件,您必须手动为这个文件授予组664的权限,以便您的登录用户和webserver用户都可以写入该日志文件。
To avoid this issue permanently you may want to setup a proper permissions when a new file is create within the storage/logs
dir by inheriting the permissions from the directory this answer https://unix.stackexchange.com/a/115632 can help you to tackle with that.
为了永久避免这个问题,您可能希望在存储/日志目录中创建新文件时,通过从目录中继承权限来设置适当的权限,这个答案https://unix.stackexchange.com/a/115632可以帮助您解决这个问题。
#3
40
For everyone using Laravel 5, Homestead and Mac try this:
对于每个使用Laravel 5的人来说,Homestead和Mac都可以试试这个:
mkdir storage/framework/views
#4
28
some times SELINUX caused this problem; you can disable selinux with this command.
有时SELINUX导致这个问题;您可以使用此命令禁用selinux。
sudo setenforce 0
#5
26
You should not give 777 permissions. It's a security risk. To Ubuntu users, in Laravel 5, I sugest to change owner for directory storage recursively:
您不应该授予777权限。这是一个安全风险。对于Ubuntu用户,在Laravel 5中,我建议递归地更改目录存储的所有者:
Try the follow:
试下:
sudo chown -R www-data:www-data storage
In Ubuntu based systems, www-data is apache user.
在基于Ubuntu的系统中,www-data是apache用户。
#6
19
Problem solved
问题解决了
php artisan cache:clear
sudo chmod -R 777 vendor storage
this enables the write permission to app , framework, logs Hope this will Help
这使写权限的应用,框架,日志希望这将会有所帮助
#7
14
For vagrant users, the solution is:
对于流浪用户,解决方案是:
(in vagrant) php artisan cache:clear
php artisan缓存:清除
(outside of vagrant) chmod -R 777 app/storage
(流浪在外)chmod - r777 app/storage
(in vagrant) composer dump-autoload
(流浪汉)作曲家dump-autoload
Making sure you chmod in your local environment and not inside vagrant is important here!
确保你在当地的环境中,而不是在流浪者内部是很重要的!
#8
10
Try again with chmod -R 755 /var/www/html/test/app/storage
. Use with sudo for Operation not permitted
in chmod. Use Check owner permission if still having the error.
再试试chmod -R 755 /var/www/ html/test/app/storageage。与sudo一起使用,用于chmod不允许的操作。如果仍然有错误,请使用Check owner权限。
#9
7
As per Laravel 5.4 which is the latest as I am writing this, if you have any problem like this, you ned to change the permission. DO NOT LISTEN TO ANYONE WHO TELLS YOU TO SET 777 FOR ANY DIRECTORY. It has a security issue. Change the permission of storage folder like this
根据Laravel 5.4,这是我写这篇文章的最新版本,如果你有任何类似的问题,你需要修改权限。不要听任何人告诉你为任何目录设置777。它有一个安全问题。像这样更改存储文件夹的权限
sudo chmod -R 775 storage
Change bootstrap folder permission like this
像这样更改引导文件夹权限
sudo chmod -R 775 bootstrap/cache
Now please make sure that you're executing both commands from your application directory. You won't face problems in future regarding permission. 775 doesn't compromise any security of your machine.
现在请确保您正在执行来自应用程序目录的两个命令。在未来你不会遇到关于许可的问题。775不会危及您的机器的任何安全性。
#10
6
If you have Laravel 5 and looking permanent solution , applicable both php artisan
command line usage and Apache server use this:
如果您有Laravel 5并正在寻找永久解决方案,那么可以使用php artisan命令行和Apache服务器:
sudo chmod -R 777 vendor storage
echo "umask 000" | sudo tee -a /etc/resolv.conf
sudo service apache2 restart
sudo chmod - r777供应商存储响应“umask 000”| sudo tee /etc/resolv重新启动conf sudo服务apache2
See detailed explanation here.
看到详细解释。
#11
6
Suggest the correct permission, if for Apache,
建议正确的权限,如果是Apache,
sudo chown -R apache:apache apppath/app/storage
#12
5
FOR ANYONE RUNNING AN OS WITH SELINUX: The correct way of allowing httpd to write to the laravel storage folder is:
对于任何使用SELINUX运行OS的人:允许httpd写入laravel存储文件夹的正确方法是:
sudo semanage fcontext -a -t httpd_sys_rw_content '/path/to/www/storage(/.*)?'
Then to apply the changes immediately:
然后立即应用这些变化:
sudo restorecon -F -r '/path/to/www/storage'
SELinux can be a pain to deal with, but if it's present then I'd STRONGLY ADVISE you learn it rather than bypassing it entirely.
SELinux可能是一个棘手的问题,但如果它存在,我强烈建议您学习它,而不是完全忽略它。
#13
4
I had the same issue and the below steps helped me fix the issue.
我遇到了同样的问题,下面的步骤帮助我解决了这个问题。
- Find out the apache user - created a test.php file in the public folder with the code
- 找到apache用户创建的测试。php文件在公共文件夹中的代码
<?php echo exec('whoami'); ?>
< ?php echo exec(“whoami”);? >
And run the file from the web browser. It would give the apache user. In my case, it is ec2-user as I was using the aws with cronjob installed in /etc/cron.d/. It could be different user for others.
并从web浏览器运行该文件。它会给apache用户。在我的例子中,它是ec -user,因为我正在使用安装在/etc/cron.d/中的aws。它可以是不同的用户。
- Run the below command on the command line.
- 在命令行上运行下面的命令。
sudo chown -R ec2-user:<usergroup> /app-path/public
sudo chown -R ec2-user:
You need to identify and use the right "user" and "usergroup" here.
您需要在这里标识并使用正确的“user”和“usergroup”。
#14
3
Xampp for use:
Xampp的使用:
cd /Applications/XAMPP/htdocs
chmod -R 775 test/app/storage
#15
3
NEVER GIVE IT PERMISSION 777!
go to the directory of the laravel project on your terminal and write:
转到您终端上的laravel项目目录,并写:
sudo chown -R your-user:www-data /path/to/your/laravel/project/
sudo find /same/path/ -type f -exec chmod 664 {} \;
sudo find /same/path/ -type d -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
This way you're making your user the owner and giving privileges:
1 Execute, 2 Write, 4 Read
1+2+4 = 7 means (rwx)
2+4 = 6 means (rw)
finally, for the storage access, ug+rwx means you're giving the user and group a 7
这样你就可以使你的用户成为所有者并给予特权:1执行,2写,4读1+2+4 = 7意味着(rwx) 2+4 = 6的意思(rw)最后,对于存储访问,ug+rwx意味着你给用户和组7。
#16
2
rm storage/logs/laravel.log
solved this for me
为我解决了这个
#17
2
If using laradock, try chown -R laradock:www-data ./storage
in your workspace container
如果使用laradock,请尝试chown -R laradock:www-data ./存储在工作区容器中
#18
1
Any time I change app.php I get a permission denied writing bootstrap/cache/services.json so I did this to fix it:
每当我修改app.php时,我都会得到一个拒绝写入引导/缓存/服务的权限。我这么做是为了修正json
chmod -R 777 bootstrap/cache/
#19
1
In my case solution was to change permission to app/storage/framework/views
and app/storage/logs
directories.
在我的案例中,解决方案是更改应用/存储/框架/视图以及应用/存储/日志目录的权限。
#20
0
If anyone else runs into a similar issue with fopen file permissions error, but is wise enough not to blindly chmod 777 here is my suggestion.
如果有人遇到类似的问题,fopen文件权限错误,但明智的做法是不要盲目地使用chmod 777。
Check the command you are using for permissions that apache needs:
检查您正在使用的命令,以获得apache所需的权限:
fopen('filepath/filename.pdf', 'r');
The 'r' means open for read only, and if you aren't editing the file, this is what you should have it set as. This means apache/www-data needs at least read permission on that file, which if the file is created through laravel it will have read permission already.
“r”的意思是为只读打开,如果你没有编辑文件,这就是你应该设置为的。这意味着apache/www-data至少需要在该文件上读取权限,如果文件是通过laravel创建的,那么它已经可以读取权限了。
If for any reason you have to write to the file:
如果由于任何原因你必须写到文件:
fopen('filepath/filename.pdf', 'r+');
Then make sure apache also has permissions to write to the file.
然后确保apache也具有写入文件的权限。
http://php.net/manual/en/function.fopen.php
http://php.net/manual/en/function.fopen.php
#21
0
Just start your server using artisian
使用artisian启动服务器
php artisian serve
php artisian服务
Then access your project from the specified URL:
然后从指定的URL访问您的项目:
#22
0
I have the same issue when running vagrant on mac. solved the problem by changing the user of Apache server in https.conf file:
我在mac上运行vagrant的时候也遇到了同样的问题,就是通过在https中改变Apache服务器的用户来解决这个问题。配置文件:
# check user for php
[vagrant] ubuntu ~ $ php -i | grep USER
USER => ubuntu
$_SERVER['USER'] => ubuntu
[vagrant] ubuntu ~ $
Run apache under php user instead of user daemon to resolve file access issue with php
使用php用户而不是用户守护进程运行apache来解决文件访问问题
# change default apache user from daemon to php user
sudo sed -i 's/User daemon/User ubuntu/g' /opt/lampp/etc/httpd.conf
sudo sed -i 's/Group daemon/Group ubuntu/g' /opt/lampp/etc/httpd.conf
now, php created cache file can be read and edit by apache without showing any access permission error.
现在,apache可以读取和编辑php创建的缓存文件,而不会显示任何访问权限错误。
#23
0
I had a similar problem. (Permission denied while the permissions where configured correct) with Laravel 5.2 and 5.5
我也有类似的问题。(权限被拒绝,而权限配置正确)使用Laravel 5.2和5.5
The problem was that SELinux was enabled which prevent Apache to write files even with 777 mode. See Solve 500 response Laravel (Uncaught UnexpectedValueException: Laravel.log) for the question and answer.
问题是启用了SELinux,使得Apache即使在使用777模式时也无法编写文件。关于问题和答案,请参阅解决500个响应Laravel(无意外值valueexception: Laravel.log)。
Maybe this solves the problem for you also.
也许这也能解决你的问题。
#24
0
After a lot of trial and error with directory permissions I ended up with an epiphany...there was no space left on the disk's partition. Just wanted to share to make sure nobody else is stupid enough to keep looking for the solution in the wrong direction.
在多次尝试和错误的目录权限之后,我终于顿悟了……磁盘分区上没有剩余空间。只是想分享,以确保没有其他人愚蠢到继续在错误的方向寻找解决方案。
In Linux you can use df -h
to check your disk size and free space.
在Linux中,可以使用df -h检查磁盘大小和空闲空间。
#25
0
Setting permission to 777 is definitely terrible idea!
将权限设置为777绝对是个糟糕的主意!
... but
…但
If you are getting permission error connected with "storage" folder that's what worked for me:
如果你得到的权限错误连接到“存储”文件夹,这对我是有效的:
1) Set "storage" and its subfolders permission to 777 with
1)将“存储”及其子文件夹权限设置为777。
sudo chmod -R 777 storage/
2) In browser go to laravel home page laravel/public/ (laravel will create necessary initial storage files)
2)在浏览器中浏览laravel主页laravel/public/ (laravel将创建必要的初始存储文件)
3) Return safe 775 permission to storage and its subfolders
3)将安全775权限返回到存储及其子文件夹
sudo chmod -R 775 storage/
#26
0
This issue actually caused by different users who wants to write/read
file but denied cause different ownership. maybe you as 'root' installed laravel before then you login into your site as 'laravel' user where 'laravel' the default ownership, so this is the actually real issue here. So when user 'laravel' want to read/write all file in disk as default, to be denied, cause that file has ownership by 'root'.
这个问题实际上是由想要写/读文件但被拒绝的不同用户引起的。也许你作为“root”安装了laravel,然后你作为“laravel”用户登录你的网站,“laravel”是默认的所有权,所以这才是真正的问题。因此,当用户“laravel”希望默认地读取/写入磁盘中的所有文件时,将被拒绝,因为该文件拥有“root”属性。
To solving this problem you can follow like this:
要解决这个问题,你可以这样做:
sudo chown -hR your-user-name /root /nameforlder
sudo chown -hR你的用户名/root /nameforlder
or in my case
或者在我的例子中
sudo chown -hR igmcoid /root /sublaravel
sudo chown -hR igmcoid /root /sublaravel。
Footnote:
补充说明:
-
root
as name first ownership who installed before - 作为之前安装的名称first ownership的根
-
your-user-name
as the default ownership who actually write/read in site. - 您的用户名作为实际在站点中编写/读取的默认所有权。
-
namefolder
as name folder that want you change the ownership. - namefolder作为名称文件夹,希望您更改所有权。
#27
0
I got same errors in my project...
But found out that I forgot to putenctype
in my form.我在项目中犯了同样的错误……但是我发现我忘记把enctype放在我的表格里了。
<form method="#" action="#" enctype="multipart/form-data">
Hopes it helps somewhere somehow...
希望它能在某个地方有所帮助……
#28
-2
For LARAVEL 5, try to create cache, sessions and views folders in storage/framework with 777 permission.
对于LARAVEL 5,尝试在存储/框架中创建具有777权限的缓存、会话和视图文件夹。
#29
-3
I have tried to give the 777
access to storage folder and it have work for me
我试图让777访问存储文件夹,它对我有帮助
1) go to your laravel root directory , (/var/www/html
for me) and run the following command
1)转到laravel根目录(/var/www/html for me)并运行以下命令
chmod 777 -R storage