Comment to 'uploading images into new album'
  • It’s very likely that the issue is related to your server’s available memory and the PHP/Nginx configuration limits. Processing time may vary depending on the operation and the number of available CPU cores, taking more or less time accordingly.

    Both have their own memory, upload size, and timeout restrictions, and when uploading large images or multiple files at once, these limits can easily be reached.

    ⚙️ PHP Configuration

    Open your php.ini file and increase the following values according to your server’s available resources:

    memory_limit = 4096M
    upload_max_filesize = 1024M
    post_max_size = 1024M
    max_execution_time = 300
    max_file_uploads = 100
    

    After making these changes, restart PHP-FPM:

    sudo systemctl restart php*-fpm
    

    🌐 Nginx Configuration

    In your Nginx site configuration file (usually /etc/nginx/sites-available/your-site.conf), increase both the upload limit and timeout values to handle large uploads:

    client_max_body_size 1024M;
    client_body_timeout 300s;
    send_timeout 300s;
    proxy_read_timeout 300s;
    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    

    Then reload Nginx:

    sudo systemctl reload nginx
    

    These settings ensure that Nginx allows large files and doesn’t interrupt long uploads or slow connections.

    🧠 Checking Server Memory

    To make sure your server has enough free memory for these operations, you can check it directly from the command line:

    1. View total and available memory:

    free -h
    

    Example output:

                  total        used        free      shared  buff/cache   available
    Mem:           7.7G        2.1G        3.4G        200M        2.2G        5.1G
    Swap:          2.0G          0B        2.0G
    

    The “available” column shows how much memory can still be safely used.

    2. Monitor memory in real time:

    htop
    

    or

    top
    

    In htop, press M to sort processes by memory usage.

    3. Get a detailed overview (optional):

    sudo apt install glances
    glances
    

    This shows memory, CPU, swap, and network usage in real time.

    🧩 Additional Recommendations

    • Check if other applications or containers are consuming excessive RAM.
    • If possible, allocate more memory to your server or optimize running services.
    • Always keep PHP and Nginx limits balanced — for example, both using a 300-second timeout.
    • If physical memory is limited, consider enabling or increasing swap space as a buffer.

    💡 Tip:

    Before adjusting any configuration, always check how much available memory your server has using free -h.

    Try to allocate around 50–60% of the available memory to PHP, leaving the rest for the operating system and other services.

    Increasing PHP and Nginx limits often solves upload issues, but it’s equally important to ensure that your server has enough free RAM to support these settings.

    You can use my script to reinstall PHP, but it only supports versions up to 8.3: https://github.com/kabballa/PHP-UNA