简体   繁体   中英

Write permission denied on Apache2 / Debian 9

I have a VPS with apache2 php-fpm running prestashop, it's been working for years, but out of a sudden, prestashop is having trouble with permissions.

Apache's user and group is set to "www-data" the same as all the files and folders in the www folder. All permissions are set to 755 and 644 but cache/smarty (Had to set those to 777 so the store could keep working.)

I've checked that its a permissions problem as prestashop cant regenerate the .htaccess file from the backoffice (unless I set it to 777).

I'm not sure what to check or what can I supply to you. Any help is welcome. Thank you all for your time.

EDIT

I've been checking the processes for "apache2" and all of them were run by www-data.

Steadweb told me to check php-fpm, seems like thats the problem. But I'm not sure where to change that.

在此处输入图片说明

Tested on Debian 9.7 , edit the following file:

/etc/php/7.0/fpm/pool.d/www.conf

And find the following, where user / group is declared. Update as follows:

...
user = www-data
group = www-data

You'll need to restart the apache / php-fpm processes

ressystemctl restart php7.0-fpm apache2

Notes

  • This is bad practice, as you're opening up privileges for php-fpm . I'd make sure that specific directories / files have write permissions.
  • Set your web directory to ownership of your user chown -R user:www-data /path/to/website
  • Use the following commands to set the permissions for directories / files for you website
cd /path/to/website
find -type d -exec chmod 750 {} \;
find -type f -exec chmod 644 {} \;
  • Then, open up specific files / directories that require writable access.

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