How to delete files created by Apache user?

Written by - 0 comments

Published on - last updated on November 23rd 2023 - Listed in PHP Apache


There is a common problem on shared hosting servers with Apache and PHP (mod_php) running on it: If a PHP or an upload script creates files and folders, the owner of those created files is the user under which Apache is running. On a Debian-based Linux that's mostly the www-data user. On SUSE Linux it's by default the wwwrun user. On RHEL and similar Enterprise Linux systems it's often the httpd user.

Users accessing their hosting by FTP/SFTP/FTPES and wanting to delete such files receive a permission denied error - because (of course) they're not allowed to delete those files. Here an example of an ls -l output:

-rw-r--r-- 1 www-data www-data 0 2010-01-16 18:30 file1
-rw-r--r-- 1 www-data www-data 0 2010-01-16 18:30 file2
-rw-r--r-- 1 www-data www-data 0 2010-01-16 18:30 file3
drwxr-xr-x 2 www-data www-data 4.0K 2010-01-16 18:30 testfolder1
drwxr-xr-x 2 www-data www-data 4.0K 2010-01-16 18:30 testfolder2
drwxr-xr-x 2 www-data www-data 4.0K 2010-01-16 18:30 testfolder3

The permissions are set in a way that only the owner (www-data here) can delete the files and directories.

So if you're someone who was seeking for a solution when you can't delete the files with your ftp user, this is it! Find more information in IT Howto's / PHP Script: Delete files and folders created by Apache user.


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences