简体   繁体   中英

Raspberry Pi 3, browser permissions on apache2 php script

Having a nightmare with permissions on RP3, apache2, php

I can run my php api script from terminal with no problems. I use the browser for debugging and get the 'permission denied' when trying to edit text files from the browser.

I have temporarily set permissions to 777 on /var/www but this is insecure, and i can no longer remember the original permissions that were on /var/www

Can i somehow give the broswer (chromium) permission to edit files in /var/www?

I have tried setting inheritance, but to no avail, as i am copying files over all the time, i have to keep resetting the permissions to 777 (which is not ideal), so i can debug the code in a browser.

Any help would be greatly appreciated

Rgds

Mike

Usually, the permissions for folders are 0755 and for folders are 0644 .

To set the permissions for folders:

sudo find /var/www -type d -exec chmod 0755 {} \;

To set the permissions for files:

sudo find /var/www -type f -exec chmod 0644 {} \;

Now about the user/group , Apache is probably using the user www-data with group www-data .

To set the user/group for write permissions:

sudo chown www-data:www-data /var/www -R

A note about security: opening up the option to edit the files from the browser is insecure without any login, allowing anyone to edit your files. Also, the write permissions should only be allowed in a directory where the users upload files and NOT for all your /var/www files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM