mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-05 00:29:48 +03:00
Permission denied ".../storage/logs/laravel.log could not be opened" #370
Closed
opened 2026-02-04 19:09:25 +03:00 by OVERLORD
·
19 comments
No Branch/Tag Specified
development
l10n_development
further_theme_development
release
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#370
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @viewty on GitHub (Jul 14, 2017).
Project Maintainer Edit - For Laravel Developers
Gaining an understanding of Unix permissions, rather than blindly setting them.
Please see the comment here: https://github.com/BookStackApp/BookStack/issues/436#issuecomment-395964366
Original Issue
Hi all,
Having a permissions problem with the install. I'll try to provide all the necessary info if some one could please help.
For Bug Reports
Expected Behaviour
Redirected after login
Actual Behaviour
HTTP Error 500
I go to docs.someurl.co and I am shown the login page. Great. I put in
admin@admin.comandpasswordand I get a HTTP Error 500.@ssddanbrown commented on GitHub (Jul 14, 2017):
Hi @viewty,
This looks like a fairly standard permission error.
The
storagefolder andbootstrap/cachefolders need to be writable by the webserver user/group. Usually this is often the user/groupwww-databut it depends on your setup.What http server are you using (Apache or nignx?) and what OS are you running BookStack on?
@viewty commented on GitHub (Jul 14, 2017):
Not sure what was going on - restarted httpd and that problem is solved.
This is with Apache on Centos 7.
I had previously done
chmod 777 -R storage bootstrap/cache public/uploadsbut I might have made a typo.Thanks for the quick reply and help.
@yemiwebby commented on GitHub (May 10, 2018):
chmod -R 777 storageworked for me@hariDasu commented on GitHub (Jun 8, 2018):
chmod -R 775 storageworked for me@ssddanbrown commented on GitHub (Jun 9, 2018):
Lol, This is the most popular page of all BookStack GitHub pages.
Hello fellow Laravel developers who have googled their writable storage issues. It's important to be aware of what permissions you are setting so I thought I'd provide a little overview. Better, more detailed guides are available via more googling.
Unix-Style Permissions
Files and folders have 3 main permissions:
read,write&execute.Files and folders are also assigned an
ownerandgroup.Reading Permissions
You can run
ls -alhin the terminal to show the files and folders with their permissions:The permissions are on the left, in the first column. The starting
dis shown if it's a directory. Then there are three sets ofrwx.rwxis the permissions for the owner.rwxis the permissions for the group.rwxis the permissions for everyone else.Each of these characters represents read, write or execute. A hyphen (
-) is shown instead if the permission is not granted. Note that execute permissions are required on folders to enter them.The owner assigned to a file/folder can be seen in the third column. The group can be seen in the fourth. In the example above the file
favicon.icois assigned to the groupdanand is owned bywww-data. The ownerwww-datahas permission to read and write the file. The groupdanhas permission to read, write, or execute the file. Everyone else can only read the file.Octal Format
Permissions may also be shown as numbers in an octal format. In the octal format each permission has a number:
These numbers are summed together into a single digit. For example, Having all permissions will be shown as a
7or only having Read+Execute permissions will be shown as a5. These totals are often used in a set of 3 to represent the permissions for the group, owner & everyone else.In the example command output above, the permissions for
favicon.icocould be shown as674. The.htaccessfile permissions could be shown as644. All permissions granted to everyone would show as777.Setting Permissions
There are two main commands for controlling permissions:
chmod(Change mode), Used to set permissions.chown(Change ownership), Used to change the owner and group.For both of these commands using
-Rwill set permissions recursively upon all child files and directories.chmod usage
chown usage
Common use
For things such as file uploads, you'd generally want these to be both readable and writable by the webserver. The user and group your web server runs as will depend on your system and config. On ubuntu it's common for apache and nginx to run as
www-data, both as the owner and group. In this case, If i wanted to give the webserver permission to upload and serve files within the./storagedirectory I might do the following:Just to reiterate, There's better and more in-depth guide elsewhere, Just have a google, but the above may help you understand what's going on when you're setting permission on your server.
@lieszkol commented on GitHub (Jul 15, 2018):
I don't remember ever seeing such a nice, concise yet in-depth overview of Unix permissions management on the net anywhere. Funny it's hidden in an obscure post on the BookStack forum. Thanks :-)
@msamgan commented on GitHub (Jul 27, 2018):
changing the permission of directory works but not a permanent solution.
when the next day a new log is created the same problem is faced again.
any solution to this ?
@ssddanbrown commented on GitHub (Jul 28, 2018):
@samgan-khan Review your permissions. Whatever process creates the log files will need write permissions on the parent directory.
@luwynne commented on GitHub (Aug 6, 2018):
Can you guys be more straight to the point? How to solve this problem?
@msamgan commented on GitHub (Aug 6, 2018):
@ssddanbrown I finally got the solution to this problem.
in logging.php->driver->daily add a permission key too with 775 and you are good to go.
it will add the permission to the created file and apache user will also be able to write in it.
@msamgan commented on GitHub (Aug 6, 2018):
@luwynne please follow the above comment and ii guess the problem will be solved.
@ssddanbrown commented on GitHub (Aug 6, 2018):
Just to be clear for BookStack users, The solution two comments above does not currently apply.
@samgan-khan Thank you for posting a solution but understand this is not the solution for everyone. Permitted permissions on this file depend on you webserver, existing permissions and how the file was originally created.
@luwynne
touch storage/logs/laravel.log && chmod 777 storage/logs/laravel.logwill probably solve this for you but is overly permissive. Since you are a developer I'd really encourage you to understand why this is happening (Hence my long post above) and I guarantee it will help in your future development work and overall save you time.@lommes commented on GitHub (Aug 6, 2018):
@ssddanbrown as far as I know, you made two minor mistakes in your explanation. The first rwx is for the user and the second for the group. Same goes for the chown command (user:group instead of group:user which you correctly used in the last code block).
But basically UNIX permissions is a must for every web developer and one of the most common errors! There is no "golden rule" since there are too many possible scenarios (OS, setup, sticky bits, ...). You need to know some facts about your hosting environment. Hosting panels will often handle user rights differently to basic manually installed webserver, some distributions use different service names (e.g. in CentOS there is no www-data user, apache is used instead, but the service is not called apache, it's httpd there). The better you know your hosting environment, the easier it is for you to track down issues (or for us to help).
Setting wrong permissions (and 777 is a wrong permission in most cases) leads to lowered security. In some cases this might lead to full disclosure of sensitive data (Log may contain mysql user and password if the mysql server is not accessible for a short time and with 777 be exposed to the web, luckily Laravel does not write user and password to the log).
An easy way to find out what user is delivering your site to the browser is to place a simple php file in your webroot and use it to create a file like:
After calling it once in your browser, with
ls -l /tmpyou will see user and group the webserver needs for reading/writing files.@ssddanbrown commented on GitHub (Aug 6, 2018):
@lommes Thanks for pointing those errors, I always muddle up the ordering in my head, Now updated 👍
Totally agree with all the above. It's an easy thing for developers to skip over and think it's just some sort of odd bug that applying
777solves but it's not as hard as it first seems to understand. It does benefit developers to have a base understanding of this.For fellow video learners:
https://www.youtube.com/watch?v=8SkN7UofOww
@pascualstromsnes commented on GitHub (Aug 8, 2018):
Another culprit behind this error could also be selinux.
See https://linuxhint.com/how-to-disable-selinux-on-centos-7/
@hamid-ne commented on GitHub (Mar 22, 2019):
Fixed my problem with this command in centos 7.6 Server
@ssddanbrown commented on GitHub (Jun 24, 2019):
@vikasrinvi That is a subtly different issue. This has been answered above already.
@ormanfaghihi commented on GitHub (Jul 23, 2019):
chmod -R 775 storagealso worked for me 😍😍😍😍😍@ssddanbrown commented on GitHub (Aug 3, 2019):
I'm going to lock this off as further comments will only really mis-guide people.
To Laravel Developers
Learn how permissions work and how to apply them correctly instead of blindly running permission commands. It will be beneficial.
To BookStack users
If you're having trouble understanding any of the above please open a new issue so that we can troubleshoot your particular scenario.