Web Server (Apache/Nginx) File Permission Tool

<p>A tool to generate optimal file and directory permissions for Apache and Nginx web servers, for secure and functional website hosting.</p>

Web Server File Permission Tool

Configure Web Server Settings

The main directory where your website files are stored

Leave empty to use default (www-data)

Leave empty to use default (www-data)

Understanding Web Server Permissions

Properly configured file and directory permissions are critical for web server security and functionality. The web server needs to read files to serve them, but overly permissive settings can lead to security vulnerabilities.

Common Permission Patterns

ItemNumericSymbolicExplanation
Directories755drwxr-xr-xOwner can read/write/traverse, others can read/traverse
HTML/CSS/JS Files644-rw-r--r--Owner can read/write, others can read only
PHP/Scripts644-rw-r--r--Same as static files (executed by the web server)
Config Files640-rw-r-----Owner can read/write, group can read, others no access
Upload Directories775drwxrwxr-xWeb server needs write access for uploads
Log Files660-rw-rw----Owner and group can read/write, others no access

Security Best Practices

  • Never set 777 (world-writable) permissions on web directories or files
  • Make sure directory contents can't be listed without an index file
  • Use 750 or stricter for sensitive configuration directories
  • Apply the principle of least privilege - give only the minimum permissions necessary
  • Regularly audit file permissions, especially after updates or installations
  • Use suEXEC, php-fpm, or similar technologies to run scripts as specific users

Web Server User Differences

Apache Users

  • Ubuntu/Debian: www-data
  • CentOS/RHEL: apache
  • Arch Linux: http
  • FreeBSD: www

Nginx Users

  • Ubuntu/Debian: www-data
  • CentOS/RHEL: nginx
  • Arch Linux: http
  • FreeBSD: www

Stay Updated with Linux Tips

Get weekly tutorials, command references, and new tool announcements delivered straight to your inbox.