What are the best practices for setting file permissions (CHMOD) for PHP installations?

Setting file permissions (CHMOD) for PHP installations is crucial for security and proper functioning of your application. A common best practice is to set directories to 755 and files to 644. This ensures that directories are executable but not writable, and files are readable but not writable by others.

// Set directory permissions to 755
chmod('/path/to/directory', 0755);

// Set file permissions to 644
chmod('/path/to/file.php', 0644);