PHP script uploads archives on the web server and unzip them. Under some conditions I need to delete previously unzipped files. But apache can not delete the files because it get "Access denied" error despite of it has all the necessary permissions. I tried to delete them as 'apache' user manually and got the same error.
For example:
# ls -l
....
-rw-r--r--. 1 apache apache 46 янв 26 11:11 desktop.ini
# sudo -u apache rm desktop.ini
rm: невозможно удалить «desktop.ini»: Отказано в доступе
^^^ It means Access Denied
I can delete the files as 'root' user. I thought that it can be by selinux restrictions. But selinux works in permissive mode:
# getenforce
Permissive
make sure that the apache service is indeed running as username 'apache' as it is typically running as username 'www-data' however I am sure you most likely have checked this already.
the user 'apache' only has write/read permissions in your above post
however to delete a file you need write/execute permissions
give the user execute permissions
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.