failed to open stream: Permission denied in /opt/lampp/htdocs

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

I am using Linux 16.04 & xampp 5.6.30. I am trying to create a simple login program using file with validation but I am facing problem while putting my data into a file named “login.txt”.

Error

file_put_contents(login.txt): failed to open stream: Permission denied in /opt/lampp/htdocs/PHP/Practice/PHP Functions/Login Validation/login.php on line 38

This error is due to file permissions. The php/apache user does not have the permissions to write in the directory. One way of fixing that is to change the mod byte of the directory with the command chmod. You need super permissions to execute this modification if your session user does not own the directory.

$ sudo chmod -R 777 /path/to/directory

The mod 777 set read/write and execution to the directory for every user on the system. The R option applies recursively the modification to every file and sub-directories. So, you can change the permission of all the contents of your htdocs directory all at once.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x