Recommended File Permissions (755 & 644) for Script Security
Proper file and folder permissions are essential to prevent unauthorized scripts from modifying your source code or executing malicious binaries.
1. Standard Linux Permissions
- Directories: Set to
755(rwxr-xr-x). Allows the web server and owner to read, write, and execute directories. - Files: Set to
644(rw-r--r--). Allows owner read/write and public read-only access. - Configuration Files: Sensitive files like
config/config.phpcan be set to640or600if your hosting environment permits.
2. Securing the Uploads Directory
User-uploaded files (such as payment receipts, avatars, and thumbnails) reside in uploads/. To prevent PHP execution inside uploads:
Ensure an .htaccess file exists inside uploads/ containing:
<FilesMatch "\.(php|php5|php7|php8|phtml|pl|py|cgi)$">
Order Deny,Allow
Deny from all
</FilesMatch>
This guarantees that even if a malicious file is uploaded, the web server refuses to execute it.
Explore more articles
Need setup assistance, code explanations, or server tutorials?
Was this article helpful?
0 developers found this helpful • Submit your feedback to notify our admin desk
Thank you! Your feedback has been sent directly to the Admin Desk.
Admin notification generated with your details and rating.