lightPHPFM - Lightweight Single-File PHP File Manager

A fast, lightweight, and modern single-file PHP file manager with no external dependencies (zero CDN links, no database needed). Designed for quick deployment, local development, VPS administration, or lightweight file sharing.


✨ Features


🚀 Quick Start

1. Requirements

2. Run with PHP's Built-in Server

Place index.php in your desired directory and run:

php -S localhost:8000 index.php

Open your browser and navigate to http://localhost:8000.

3. Default Login Credentials


⚙️ Configuration

lightPHPFM can be configured in two ways:

  1. External Config File (config.php): Copy config.sample.php to config.php in the same directory. Any settings in config.php override internal defaults without touching index.php.
  2. Internal Settings (index.php): If no config.php file exists, index.php uses its built-in internal settings.

1. Selecting the Root Folder

You can specify where the root folder is located:

Option A: Single Root Directory

Set an absolute path or relative path to any folder on your server:

// In config.php or index.php:
'root_dir' => __DIR__ . '/uploads',      // Browse inside the "uploads" subfolder
// 'root_dir' => '/var/www/html/storage',// Absolute Linux path
// 'root_dir' => 'D:/MyStorage',         // Windows path

Option B: Multiple Selectable Root Folders

You can define multiple root folders. When configured, an interactive Root selector dropdown appears in the top navigation bar, allowing users to switch between root directories on the fly:

'root_dirs' => [
    'Main Project' => __DIR__,
    'Uploads'      => __DIR__ . '/uploads',
    'Logs'         => '/var/log',
],

2. Read-Only Access Mode

You can configure read-only mode either globally for everyone, or on a per-user basis:

Global Read-Only Access

Disables upload, create, edit, rename, and delete for all visitors. The UI switches to viewer mode and shows a [READ-ONLY] badge:

'read_only' => true,

Per-User Read-Only Access

Grant full write access to administrators while restricting guest/viewer accounts to read-only access:

'users' => [
    // Full write access
    'admin' => 'admin',

    // Read-only user
    'viewer' => [
        'password'  => 'guest123',
        'read_only' => true,
    ],
],

3. Full Configuration Reference

return [
    'auth_enabled' => true,
    'users' => [
        'admin' => 'admin',
    ],
    'root_dir' => __DIR__,
    // 'root_dirs' => ['Site' => __DIR__, 'Uploads' => __DIR__ . '/uploads'],
    'read_only' => false,
    'hide_hidden_files' => true,
    'max_upload_size' => 128 * 1024 * 1024,
    'datetime_format' => 'Y-m-d H:i:s',
];

Generating a New Password Hash

To generate a secure bcrypt password hash in PHP:

php -r "echo password_hash('your_new_password', PASSWORD_DEFAULT) . PHP_EOL;"

Copy the generated hash into $CONFIG['users']['username'].


🌐 Web Server Deployment

Apache

Ensure AllowOverride All is enabled and mod_rewrite is active if needed. No special configuration is required; simply place index.php in your DocumentRoot or a subfolder.

To increase upload file size limits in .htaccess:

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 300
php_value max_input_time 300

Nginx

Example virtual host configuration:

server {
    listen 80;
    server_name files.example.com;
    root /var/www/lightphpfm;
    index index.php;

    client_max_body_size 128M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

🔒 Security Best Practices

  1. Change the Default Password: Immediately update the admin password before exposing lightPHPFM to any network or public internet.
  2. Use HTTPS: Always serve the file manager over SSL/TLS (HTTPS) to protect session cookies and authentication credentials in transit.
  3. Restrict Access by IP: In production environments, consider restricting access to trusted IP addresses via web server rules or VPN.
  4. PHP Upload Limits: Adjust upload_max_filesize and post_max_size in php.ini to match your intended file upload requirements.

📄 License

MIT License. Free for personal and commercial use.