Laravel 存储文件夹的服务器前提重置

时间:2021-02-14 16:26:44

标签: laravel ubuntu nginx

我有一个问题,我的存储文件夹上的服务器前提每 2 天重置一次。所以我运行这些命令并修复它:

sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache

chmod -R 775 storage 
chmod -R 775 bootstrap/cache

问题是错误再次出现,如下所示:

the stream or file could not be opened in append mode: failed to open stream: permission denied

所以我在运行命令之前和之后截取了屏幕截图及其: enter image description here

所以在运行存储拥有者之前:

drwxrwxrwx  6 www-data www-data      4096 Nov  7 02:00  storage

之后

drwxrwxr-x  6 root     www-data      4096 Nov  7 02:00  storage

1 个答案:

答案 0 :(得分:1)

这是因为 git。例如,当运行 git pull 时,它将文件的所有者更改为 root 用户。您可以通过 www-data 用户运行 git 命令或在每个 git 命令后将文件的所有者更改为 www-data。

git pull 作为 www-data 用户的示例

sudo -u www-data git pull origin master
相关问题