【发布时间】:2017-09-01 13:38:13
【问题描述】:
昨天我安装了一个带有 Apache、MySQL 和 PHP 7.0.17 的全新 CentOS 7 虚拟机。
之后,我安装了 composer 和所有其他必需的 php 包。
然后我按照本指南安装 Firefly-iii:https://firefly-iii.github.io/using-installing.html。
到目前为止一切顺利。数据库是从 php artisan migrate 命令迁移和播种的。
现在的问题是,当我尝试从浏览器访问应用程序时,出现 500 错误。没有日志规则,什么都没有。
好的,这可能是权限问题。我已将所有者更改为 apache:apache,没有结果。将 storage 和 bootstrap/cache 文件夹设置为 777 无结果。
好吧...现在怎么办。啊,也许用户或用户组不正确。我已经复制了我的 public/index.php 并内置了一些 try catch 语句(仍然没有日志)。
当我在浏览器中打开应用程序时,最终会返回一些结果。
这个尝试/捕获:
try {
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
} catch (Exception $e){
echo $e->getMessage();
echo '<br/>';
echo 'User: '.exec('whoami');
echo '<br/>';
echo 'Group: '.exec('groups');
echo '<br/>';
}
返回以下结果:
The stream or file "/var/www/html/application-folder/storage/logs/application-name-2017-04-06.log" could not be opened: failed to open stream: Permission denied
User: apache
Group: apache
收到此消息后,我创建了 /var/www/html/application-folder/storage/logs/application-name-2017-04-06.log 文件并将权限更改为 777。
这是我的 bash 历史的一小部分:
[user@16 logs]$ sudo chmod 777 firefly-iii-2017-04-06.log
[sudo] password for user:
[user@16 logs]$ ls -l
-rwxrwxrwx+ 1 apache apache 5 Apr 6 14:18 firefly-iii-2017-04-06.log
[user@16 logs]$ chmod 777 firefly-iii-2017-04-06.log
chmod: changing permissions of ‘firefly-iii-2017-04-06.log’: Operation not permitted
此错误消息仍在返回,目前我不知道还有什么办法可以解决此问题。
有没有人知道解决方案或有其他人期待这种奇怪的行为?
请帮助我,我现在完全陷入困境,不知道现在该怎么办以及如何解决这个问题。
【问题讨论】:
-
你必须设置所有storage文件夹的权限
-
是的,我知道我必须为整个存储文件夹设置权限。我还将整个项目文件夹设置为 777。但这一切都不能解决问题。
-
可能你设置的权限不对...请手动检查文件的权限。
-
我尝试使用 chmod 777、chmod a+rw、setfacl 设置权限,并使用 chown apache:apache 将用户更改为 apache。我真的不知道设置权限的其他方式。
-
你是用 -r 参数做的吗?
标签: apache laravel permissions centos selinux