Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.8K
Views
The stream or file could not be opened in append mode: failed to open stream: Permission denied

I'm hosting a Laravel project inside a RHEL 7 machine using NGINX and PHP7.4-fpm

in my nginx.conf, I set the user as the following

user nexta;

while in my .../.../php-fpm.d/www.conf

user = nexta
group = nexta

listen = /var/run/php-fpm/php-fpm.sock

listen.owner = nexta
listen.group = nexta
listen.mode = 0660

Using this setup, I managed to run the Laravel application, however, I am stuck with the permission denied error

It says:

The stream or file "/home/nexta/mywebsite.com/storage/logs/laravel-2021-07-25.log" could not be opened in append mode: failed to open stream: Permission denied

I have tried the followings

  1. Setting the chown and chmod
sudo chown -R nexta:nexta /home/nexta/mywebsite.com
sudo chown -R nexta:nexta /home/nexta/mywebsite.com/storage
sudo chown -R nexta:nexta /home/nexta/mywebsite.com/bootstrap/cache

sudo chmod -R 775 /home/nexta/mywebsite.com/storage
sudo chmod -R 775 /home/nexta/mywebsite.com/bootstrap/cache
  1. tried to use 777 (I know it's not a good practice)
sudo chmod -R 777 /home/nexta/mywebsite.com/storage
sudo chmod -R 777 /home/nexta/mywebsite.com/bootstrap/cache
  1. changed the user in nginx.conf to nginx and chown the site to nginx. The error still prevails and also I am unable to view my application

  2. Ran the followings:

php artisan cache:clear
composer dumpautoload

What I also noticed, if I run php artisan cahce:clear (notice the typo), this triggers an error and the app able to access the log file, yet the when the app is accessed through http request, the app is unable to access the log file.

I also try to echo whoami in the php request (using a non laravel application), I got the following response

Returned with status 0 and output: Array ( [0] => nexta )

which means, when the app is executed by http request, the user is nexta.

At this point, I'm not even sure what causes the error.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You should have a lock on the file for any reason.

You can solve he pb by either :

rm <log file>

or if you want to keep it

mv <log file> <log_file>-old
over 4 years ago · Santiago Trujillo Report

0

For whatever reason, the following command fix my issue

chcon -R -t httpd_sys_rw_content_t storage

chcon -R -t httpd_sys_rw_content_t bootstrap/cache
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!