简体   繁体   中英

Laravel: Newly created log file has ownership issues

In my laravel project, in /storage/logs folder, there is log file created daily. If that file is created by apache then the owner and owner group becomes www-data and if the file is created by vs-code it's owner and owner group becomes habib (because vs-code is running under habib user)

Here is the problem.

-In first case when apache create that file, then it gives error if vs-code want to edit this file.

-In second case when vs-code create that file, then it gives error if apache want to edit this file.

Error is: The stream of file could not be opened in append mode.

How I solved this problem daily?

Welll, everyday I'm running the following command to get rid of that above error, I manually set ownership of file

sudo chown habib:www-data laravel-2021-03-22.log

在此处输入图像描述

What did I want? I wanted to set the ownership in such a way that it will automatically make the owner of the newly created file as habib and the owner group as www-data when the file is created. Plz, tell me whether it's a correct solution or not, and if yes then how to implement that?

use below command in your app directory to gave access permission on storage directory.
sudo chmod -R 777 storage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM