Error during file download
How to solve http 500 error during file upload?
Overview: This article explains how to resolve an HTTP 500 error that occurs during file download by increasing the values of max_execution_time, memory_limit, post_max_size, and upload_max_filesize in the PHP configuration (php.ini file).
To resolve the above error, increase the values for max_execution_time, memory_limit, post_max_size, and upload_max_filesize in the php.ini file. Refer to the steps below.
Step 1: Run the following command to verify the current settings in the php.ini file. Replace 8.2 with the PHP version installed on your system.
root@gateway :~# grep -v '^\s*#' /etc/php/8.2/apache2/php.ini | grep -i ---> (change into corresponding PHP version) 'max_execution_time\|post_max_size\|upload_max_filesize\|memory_limit\|max_input_time'
max_input_time
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
post_max_size = 8M
upload_max_filesize = 2M
For the PHP CLI configuration:
root@gateway :~# grep -v '^\s*#' /etc/php/8.2/cli/php.ini | grep -i 'max_execution_time\|post_max_size\|upload_max_filesize\|memory_limit\|max_input_time'
max_input_time
max_execution_time = 30
max_input_time = 60
memory_limit = -1
post_max_size = 8M
upload_max_filesize = 2M
Step 2: Open the php.ini files using a text editor and update the values as needed. Update the following directives to higher values, for example:
root@gateway :~# vim /etc/php/8.2/apache2/php.ini ---> (change into corresponding PHP version)
max_execution_time = 300
max_input_time = 600
memory_limit = 1G
post_max_size = 1G
upload_max_filesize = 1G
For the PHP CLI configuration:
root@gateway :~# vim /etc/php/8.2/cli/php.ini
max_execution_time = 300
max_input_time = 600
memory_limit = 1G
post_max_size = 1G
upload_max_filesize = 1G
Step 3: After making the changes, restart the Apache web service to apply the new configuration.
root@gateway :~# systemctl restart apache2
Step 4: Run the following command again to confirm the updated values:
root@gateway :~# grep -v '^\s*#' /etc/php/8.2/apache2/php.ini | grep -i 'max_execution_time\|post_max_size\|upload_max_filesize\|memory_limit\|max_input_time'
max_input_time = 600
max_execution_time = 300
memory_limit = 1G
post_max_size = 1G
upload_max_filesize = 1G
For the PHP CLI configuration:
root@gateway :~# grep -v '^\s*#' /etc/php/8.2/cli/php.ini | grep -i 'max_execution_time\|post_max_size\|upload_max_filesize\|memory_limit\|max_input_time'
max_input_time = 600
max_execution_time = 300
memory_limit = 1G
post_max_size = 1G
upload_max_filesize = 1G
Related Articles:
Transfer file from desktop machine to remote server