skip to Main Content

I am using Ubuntu 22.04 with the latest version of Docker Desktop (4.11.1) and Laravel Framework 9.26.1.

I try to create a new Laravel project follwing the steps listed at https://laravel.com/docs/9.x#getting-started-on-linux.

When I run ./vendor/bin/sail up the terminal shows no errors.
But when I try to access http://localhost/ Laravel shows this UnexpectedValueException:

The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: file_put_contents(/var/www/html/storage/framework/views/d21bc1965d8c501e5e18921c4eb8ea6ec1e5686e.php): Failed to open stream: Permission denied Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}}

However, running php artisan serve works without problems.
Why is Sail not working?

3

Answers


  1. These are the steps I would take to resolve.

    • Tear down the containers ./vendor/bin/sail down.
    • Make sure you are using the Ubuntu user you intend to use. whoami
    • Add your Ubuntu user to the ‘docker’ group so you don’t have to use sudo for Docker. usermod -a -G docker myusername.
    • Check the owner of the file executing in the terminal ls -la storage/logs. If your Ubuntu user is not the owner, you should make your user the owner. chown UbuntuUserName:UbuntuUserGroup -R /path/to/the/laravel/app/storage/logs. I would more than likely run that on the app directory as the files likely belong to a different user if the log file does as well..

    Also check the permissions on the file. See what an authorized group is allowed to perform on that file.

    • Rerun the command ./vendor/bin/sail up
    Login or Signup to reply.
  2. not nice but working quickly – open the directories world writable

    sudo chmod o+w -R database/
    sudo chmod o+w -R routes/
    sudo chmod o+w -R resources/
    sudo chmod o+w -R storage/
    
    Login or Signup to reply.
  3. sail root-shell
    cd ..
    chown -R sail:sail html
    

    Use the sail command, enter the root-shell, enter the sail as the root user and then change the html folder permission.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search