I'm pretty new at laravel, in fact and I'm trying to create my very first project. for some reason I keep getting this error (I haven't even started coding yet)
我是laravel的新手,事实上,我正在尝试创建我的第一个项目。由于某种原因,我一直在犯这个错误(我还没有开始编码)
Error in exception handler: The stream or file "/var/www/laravel/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/laravel/bootstrap/compiled.php:8423
I've read this has something to do with permissions but chmod -R 775 storage
didn't help at all.
我读过这与权限有关,但是chmod -R 775存储根本不起作用。
13 个解决方案
#1
47
Sometimes we need to do more, because
有时我们需要做得更多,因为
chmod -R 775 storage
Means
意味着
7 - Owner can write
7 - Group can write
5 - Others cannot write!
If your webserver is not running as Vagrant, it will not be able to write to it, so you have 2 options:
如果您的web服务器没有以流浪方式运行,那么它将无法对它进行写入操作,因此您有两个选项:
chmod -R 777 storage
or change the group to your webserver user, supposing it's www-data
:
或者将组更改为您的webserver用户,假设是www-data:
chown -R vagrant:www-data storage
#2
38
So, if anyone else is having this problem, here's what you do.
所以,如果其他人有这个问题,这就是你要做的。
- Get out of the VM
- 离开虚拟机
- Using the console, go to your synced folder (vagrant)
- 使用控制台,转到同步文件夹(流浪)
$ sudo chmod -R 777 app/storage
- $ sudo chmod -R 777应用/存储。
Even though I created the project within the VM using the VM user, the folder belonged to the user in the real computer; so, whent trying to did chmod 777 I got chmod 775.
虽然我使用VM用户在VM中创建了项目,但实际计算机中的文件夹属于用户;所以,当我尝试做chmod 777时,我得到了chmod 775。
Now it's working.
现在的工作。
Thanks to all those that helped me figure this thing out
感谢那些帮助我弄明白这件事的人
EDIT:
编辑:
Actually, it wasn't working, it still gave me a "permission denied" problem.
实际上,它不工作,它仍然给我一个“拒绝承认”的问题。
Here's what I did, I modified my Vagrantfile like this:
这是我所做的,我修改了我的流浪文件
config.vm.synced_folder "./app","/var/www/", create:true,
:owner => "vagrant",
:group => "www-data",
:mount_options => ["dmode=775","fmode=664"]
#3
37
Never set a directory to 777. you should change directory ownership. so set your current user that you are logged in with as owner and the webserver user (www-data, apache, ...) as the group. You can try this:
永远不要将目录设置为777。您应该更改目录所有权。因此,将您当前登录的用户设置为该组的所有者和web服务器用户(www-data, apache,…)。你可以试试这个:
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
then to set directory permission try this:
然后要设置目录权限,请尝试以下操作:
chmod -R 775 storage
chmod -R 775 bootstrap/cache
Update:
更新:
Webserver user and group depend on your webserver and your OS. to figure out what's your web server user and group use the following commands. for nginx use:
Webserver用户和组依赖于您的Webserver和OS。要弄清楚您的web服务器用户和组使用以下命令是什么。nginx的使用:
ps aux|grep nginx|grep -v grep
如果是|grep nginx|grep -v grep
for apache use:
apache使用:
ps aux | egrep '(apache|httpd)'
ps aux |白鹭(apache|httpd)
#4
17
You need to adjust the permissions of storage
and bootstrap/cache
.
您需要调整存储和引导/缓存的权限。
-
cd
into your Laravel project. - cd进入你的Laravel项目。
sudo chmod -R 777 storage
- sudo chmod - r777存储
sudo chmod -R 777 bootstrap/cache
- sudo chmod - r777引导/缓存
Depending on how your web server is setup, you may be able to be more specific with your permissions, and only grant them to your web server user. Google WEB SERVER NAME Laravel file permissions
for more information.
根据web服务器的设置方式,您可以对您的权限进行更具体的设置,并只将其授予web服务器用户。更多信息请访问谷歌WEB服务器名称Laravel文件权限。
At the time of writing, this is for Laravel 5.4
在撰写本文时,这是为Laravel 5.4编写的
#5
3
This solution is specific for laravel 5.5
此解决方案针对laravel 5.5。
You have to change permissions to a few folders: chmod -R -777 storage/logs chmod -R -777 storage/framework for the above folders 775 or 765 did not work for my project
您必须将权限更改为几个文件夹:chmod -R -777存储/log chmod -R -777存储/框架,用于上述文件夹775或765对我的项目不起作用
chmod -R 775 bootstrap/cache
Also the ownership of the project folder should be as follows (current user):(web server user)
此外,项目文件夹的所有权应该如下(当前用户):(web服务器用户)
#6
1
I wasn't too keen on changing my folder permissions to 777. Here's how I went about fixing this issue.
我不太喜欢将文件夹权限更改为777。以下是我解决这个问题的方法。
First, I changed the user who is running the web server on my local machine(I run nginx, but the principles apply everywhere):
首先,我更改了在本地机器上运行web服务器的用户(我运行nginx,但是这些原则适用于所有地方):
$> sudo vim /etc/nginx/nginx.conf
user <my_user> #inside nginx.conf
service nginx reload
Afterwards, I created another index.php
file under the public/
folder to find out who was running my php-fpm version and where I would go about changing that:
之后,我创建了另一个索引。php文件下的公共/文件夹,以找出谁在运行我的php-fpm版本,我将在哪里进行更改:
<?php
phpinfo();
?>
Reloading the page, I found out that www-data
was the user(under the environment section). I also found out I was running php 7.1. I proceeded to change the user:
重载页面时,我发现www-data是用户(在environment部分)。我还发现我正在运行php 7.1。我开始改变用户:
$> sudo vim /etc/php/7.0/fpm/pool.d/www.conf
#Look for www-data or the following variables: user, group, listen.user, listen.group.
Finally, I gave the following permissions to folders:
最后,我给文件夹下了以下权限:
sudo chmod -R 775 ./storage/
Now, I made sure that I was the owner of the folders by using a simple:
现在,我通过使用一个简单的:
ls -al
If you set the server and php-fpm users to yourself and the folders are owned by root for example, then you will keep encountering this issue. This can happen if you did a sudo laravel new <project>
as root. In that case, make sure you use a recursive chown
command on your project to change the user:group
settings. In most default cases, www-data
is the main setting for the server and php, in that case it's a matter of making sure the folder isn't out of www-data
's reach.
如果您将服务器和php-fpm用户设置为自己,并且这些文件夹为root所有,那么您将继续遇到这个问题。如果您使用sudo laravel的新
My project is setup in my home directory. On Ubuntu 16.04 and Laravel 5.5.
我的项目是在我的主目录中设置的。在Ubuntu 16.04和Laravel 5.5上。
#7
1
This error can be fixed by disabling Linux.
这个错误可以通过禁用Linux来修复。
Check if it has been enabled
检查它是否已启用
sestatus
sestatus
You try..
你试试. .
setenforce 0
setenforce 0
#8
1
try this
试试这个
- cd /var/www/html
- cd /var/www/html
- setenforce 0
- setenforce 0
- service httpd restart
- 服务httpd重启
#9
0
For windows users
对于windows用户
1: Click Start, type INetMgr.exe, and then click Enter. If prompted, click Continue to elevate your permissions.
1:单击Start,输入INetMgr。exe,然后单击Enter。如果提示,单击“继续提升权限”。
2: In the Connections section, click the + button next to the name of your computer.
2:在连接部分,单击计算机名称旁边的+按钮。
3: In IIS Manager, double-click the site that you want to administer.
3:在IIS管理器中,双击要管理的站点。
4: In the Features View, double-click Authentication.
4:在功能视图中,双击身份验证。
5: Select Anonymous Authentication, and then click Edit in the Actions pane.
5:选择匿名身份验证,然后单击Actions窗格中的Edit。
6: In the Edit Anonymous Authentication Credentials dialog box, click the Specific user option, and then click Set.
6:在“编辑匿名身份验证凭证”对话框中,单击特定的用户选项,然后单击“设置”。
7: In the Set Credentials dialog box, input the user name and password desired, and then click OK.
7:在Set凭证对话框中输入所需的用户名和密码,然后单击OK。
#11
0
Run following commands and you can add sudo
at starting of command depends on your system:
运行以下命令,您可以添加sudo在启动时,取决于您的系统:
chmod -R 777 storage/framework
chmod -R 777 storage/logs
chmod -R 775 bootstrap/cache
#12
0
I faced the same issue and above answers didn't help me in my case for the same error. Renaming bootstrap/cache/config.php
to bootstrap/cache/config1.php
solved the issue. Deleting config.php
will also work.
我面临着同样的问题,上面的答案对我同样的错误没有帮助。重命名引导/缓存/配置。php引导/缓存/ config1。php解决了这个问题。删除配置。php也会工作。
#13
-1
SELinux management tools
SELinux管理工具
work for my project
为我的项目工作
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/datacenter/storage(/.*)?'
restorecon -Rv '/usr/share/nginx/html/datacenter/'
#1
47
Sometimes we need to do more, because
有时我们需要做得更多,因为
chmod -R 775 storage
Means
意味着
7 - Owner can write
7 - Group can write
5 - Others cannot write!
If your webserver is not running as Vagrant, it will not be able to write to it, so you have 2 options:
如果您的web服务器没有以流浪方式运行,那么它将无法对它进行写入操作,因此您有两个选项:
chmod -R 777 storage
or change the group to your webserver user, supposing it's www-data
:
或者将组更改为您的webserver用户,假设是www-data:
chown -R vagrant:www-data storage
#2
38
So, if anyone else is having this problem, here's what you do.
所以,如果其他人有这个问题,这就是你要做的。
- Get out of the VM
- 离开虚拟机
- Using the console, go to your synced folder (vagrant)
- 使用控制台,转到同步文件夹(流浪)
$ sudo chmod -R 777 app/storage
- $ sudo chmod -R 777应用/存储。
Even though I created the project within the VM using the VM user, the folder belonged to the user in the real computer; so, whent trying to did chmod 777 I got chmod 775.
虽然我使用VM用户在VM中创建了项目,但实际计算机中的文件夹属于用户;所以,当我尝试做chmod 777时,我得到了chmod 775。
Now it's working.
现在的工作。
Thanks to all those that helped me figure this thing out
感谢那些帮助我弄明白这件事的人
EDIT:
编辑:
Actually, it wasn't working, it still gave me a "permission denied" problem.
实际上,它不工作,它仍然给我一个“拒绝承认”的问题。
Here's what I did, I modified my Vagrantfile like this:
这是我所做的,我修改了我的流浪文件
config.vm.synced_folder "./app","/var/www/", create:true,
:owner => "vagrant",
:group => "www-data",
:mount_options => ["dmode=775","fmode=664"]
#3
37
Never set a directory to 777. you should change directory ownership. so set your current user that you are logged in with as owner and the webserver user (www-data, apache, ...) as the group. You can try this:
永远不要将目录设置为777。您应该更改目录所有权。因此,将您当前登录的用户设置为该组的所有者和web服务器用户(www-data, apache,…)。你可以试试这个:
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
then to set directory permission try this:
然后要设置目录权限,请尝试以下操作:
chmod -R 775 storage
chmod -R 775 bootstrap/cache
Update:
更新:
Webserver user and group depend on your webserver and your OS. to figure out what's your web server user and group use the following commands. for nginx use:
Webserver用户和组依赖于您的Webserver和OS。要弄清楚您的web服务器用户和组使用以下命令是什么。nginx的使用:
ps aux|grep nginx|grep -v grep
如果是|grep nginx|grep -v grep
for apache use:
apache使用:
ps aux | egrep '(apache|httpd)'
ps aux |白鹭(apache|httpd)
#4
17
You need to adjust the permissions of storage
and bootstrap/cache
.
您需要调整存储和引导/缓存的权限。
-
cd
into your Laravel project. - cd进入你的Laravel项目。
sudo chmod -R 777 storage
- sudo chmod - r777存储
sudo chmod -R 777 bootstrap/cache
- sudo chmod - r777引导/缓存
Depending on how your web server is setup, you may be able to be more specific with your permissions, and only grant them to your web server user. Google WEB SERVER NAME Laravel file permissions
for more information.
根据web服务器的设置方式,您可以对您的权限进行更具体的设置,并只将其授予web服务器用户。更多信息请访问谷歌WEB服务器名称Laravel文件权限。
At the time of writing, this is for Laravel 5.4
在撰写本文时,这是为Laravel 5.4编写的
#5
3
This solution is specific for laravel 5.5
此解决方案针对laravel 5.5。
You have to change permissions to a few folders: chmod -R -777 storage/logs chmod -R -777 storage/framework for the above folders 775 or 765 did not work for my project
您必须将权限更改为几个文件夹:chmod -R -777存储/log chmod -R -777存储/框架,用于上述文件夹775或765对我的项目不起作用
chmod -R 775 bootstrap/cache
Also the ownership of the project folder should be as follows (current user):(web server user)
此外,项目文件夹的所有权应该如下(当前用户):(web服务器用户)
#6
1
I wasn't too keen on changing my folder permissions to 777. Here's how I went about fixing this issue.
我不太喜欢将文件夹权限更改为777。以下是我解决这个问题的方法。
First, I changed the user who is running the web server on my local machine(I run nginx, but the principles apply everywhere):
首先,我更改了在本地机器上运行web服务器的用户(我运行nginx,但是这些原则适用于所有地方):
$> sudo vim /etc/nginx/nginx.conf
user <my_user> #inside nginx.conf
service nginx reload
Afterwards, I created another index.php
file under the public/
folder to find out who was running my php-fpm version and where I would go about changing that:
之后,我创建了另一个索引。php文件下的公共/文件夹,以找出谁在运行我的php-fpm版本,我将在哪里进行更改:
<?php
phpinfo();
?>
Reloading the page, I found out that www-data
was the user(under the environment section). I also found out I was running php 7.1. I proceeded to change the user:
重载页面时,我发现www-data是用户(在environment部分)。我还发现我正在运行php 7.1。我开始改变用户:
$> sudo vim /etc/php/7.0/fpm/pool.d/www.conf
#Look for www-data or the following variables: user, group, listen.user, listen.group.
Finally, I gave the following permissions to folders:
最后,我给文件夹下了以下权限:
sudo chmod -R 775 ./storage/
Now, I made sure that I was the owner of the folders by using a simple:
现在,我通过使用一个简单的:
ls -al
If you set the server and php-fpm users to yourself and the folders are owned by root for example, then you will keep encountering this issue. This can happen if you did a sudo laravel new <project>
as root. In that case, make sure you use a recursive chown
command on your project to change the user:group
settings. In most default cases, www-data
is the main setting for the server and php, in that case it's a matter of making sure the folder isn't out of www-data
's reach.
如果您将服务器和php-fpm用户设置为自己,并且这些文件夹为root所有,那么您将继续遇到这个问题。如果您使用sudo laravel的新
My project is setup in my home directory. On Ubuntu 16.04 and Laravel 5.5.
我的项目是在我的主目录中设置的。在Ubuntu 16.04和Laravel 5.5上。
#7
1
This error can be fixed by disabling Linux.
这个错误可以通过禁用Linux来修复。
Check if it has been enabled
检查它是否已启用
sestatus
sestatus
You try..
你试试. .
setenforce 0
setenforce 0
#8
1
try this
试试这个
- cd /var/www/html
- cd /var/www/html
- setenforce 0
- setenforce 0
- service httpd restart
- 服务httpd重启
#9
0
For windows users
对于windows用户
1: Click Start, type INetMgr.exe, and then click Enter. If prompted, click Continue to elevate your permissions.
1:单击Start,输入INetMgr。exe,然后单击Enter。如果提示,单击“继续提升权限”。
2: In the Connections section, click the + button next to the name of your computer.
2:在连接部分,单击计算机名称旁边的+按钮。
3: In IIS Manager, double-click the site that you want to administer.
3:在IIS管理器中,双击要管理的站点。
4: In the Features View, double-click Authentication.
4:在功能视图中,双击身份验证。
5: Select Anonymous Authentication, and then click Edit in the Actions pane.
5:选择匿名身份验证,然后单击Actions窗格中的Edit。
6: In the Edit Anonymous Authentication Credentials dialog box, click the Specific user option, and then click Set.
6:在“编辑匿名身份验证凭证”对话框中,单击特定的用户选项,然后单击“设置”。
7: In the Set Credentials dialog box, input the user name and password desired, and then click OK.
7:在Set凭证对话框中输入所需的用户名和密码,然后单击OK。
#10
#11
0
Run following commands and you can add sudo
at starting of command depends on your system:
运行以下命令,您可以添加sudo在启动时,取决于您的系统:
chmod -R 777 storage/framework
chmod -R 777 storage/logs
chmod -R 775 bootstrap/cache
#12
0
I faced the same issue and above answers didn't help me in my case for the same error. Renaming bootstrap/cache/config.php
to bootstrap/cache/config1.php
solved the issue. Deleting config.php
will also work.
我面临着同样的问题,上面的答案对我同样的错误没有帮助。重命名引导/缓存/配置。php引导/缓存/ config1。php解决了这个问题。删除配置。php也会工作。
#13
-1
SELinux management tools
SELinux管理工具
work for my project
为我的项目工作
semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/nginx/html/datacenter/storage(/.*)?'
restorecon -Rv '/usr/share/nginx/html/datacenter/'