Jump to content

Hello,

 

I'm getting permission denied when I try to file_put_content on /etc/nginx/sites-available/test

 

I did set the owner of the files to www-data.

 

What do I have to do?

 

Q: Why do I need to edit the file?

A: Creating a admin dashboard :P

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/820994-php-file_put_content-permission-denied-linux/
Share on other sites

Link to post
Share on other sites

1 hour ago, M.Yurizaki said:

If you do ls -l, does it show you have rw privileges on it? If not, you need to set such using chmod.

 

1 hour ago, unijab said:

What are folder permissions/owner/group?

 

Folders

drwxr-xr-x 2 www-data root 4096 Aug 10 20:01 sites-available
drwxr-xr-x 2 www-data root 4096 Aug 10 20:02 sites-enabled


Files

-rw-r--r-- 1 www-data root  741 Aug 10 20:01 file4
-rw-r--r-- 1 www-data root  739 Aug 10 20:01 file3
-rw-r--r-- 1 www-data root 2074 Feb 11 22:00 file2
-rw-r--r-- 1 www-data root  739 Aug 10 19:52 file1

 

Back-end developer, electronics "hacker"

Link to post
Share on other sites

1 hour ago, Joveice said:

 


Folders

drwxr-xr-x 2 www-data root 4096 Aug 10 20:01 sites-available
drwxr-xr-x 2 www-data root 4096 Aug 10 20:02 sites-enabled


Files

-rw-r--r-- 1 www-data root  741 Aug 10 20:01 file4
-rw-r--r-- 1 www-data root  739 Aug 10 20:01 file3
-rw-r--r-- 1 www-data root 2074 Feb 11 22:00 file2
-rw-r--r-- 1 www-data root  739 Aug 10 19:52 file1

 

Unless security is utmost important here, I usually set the same permissions to everything. Since you only need write, I'd do chmod 666.

 

Otherwise if you're running the process as another user, it won't have write access to the files.

Link to post
Share on other sites

17 minutes ago, M.Yurizaki said:

Unless security is utmost important here, I usually set the same permissions to everything. Since you only need write, I'd do chmod 666.

 

Otherwise if you're running the process as another user, it won't have write access to the files.

I need to read, write, delete and create.

Back-end developer, electronics "hacker"

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×