Very long PHP operation: 500 Internal Server Error - php

I am reading 10,000 csv files each has 1000 rows and remove the duplicate and create new file
For that
I read line by line and store the data in a array.
When I store new data in the array, I check the weather it is not duplicate (weather the array already have the data)
Then recreate csv using array
Additionally I changed following in the php.ini
max_execution_time = 30000
max_input_time = 60000
memory_limit = -1
error_log = error_log
But I am getting following error. There is no error log. Is there any other configuration to change in the php.ini. Please help me on it
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#xxxxxx.com and
inform them of the time the error occurred, and anything you might
have done that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.

Apart from checking for the Apache Timeout, you should try to break this script once & try to run it in batches of probably 2000 csv files.
It is also possible that some data in one of the CSV files is causing this error, which would be identified if you break it in batches of 2000 files & run.

Related

Reasons of 500 internal server error in php

I am trying to upload the large image(1 MB) files on server using php code but it is
showing the 500 internal server error it is only uploading up to 128 KB.
Even though i have checked all the required setting of my server
all settings are correct i am not getting how to trace this error.Is
there any other setting which i don't know so please help me to find out or
if all settings is fine then please help me trace out this 500 internal server error.
Settings which i have already verified.
memory_limit 90M
post_max_size 64M
upload_max_filesize 64M
FcgidMaxRequestLen 104857600
Below is the error:
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Use two lines at the top of the page to display errors
ini_set("display_errors", "1");
error_reporting(E_ALL);

Uploading large file (45MB) via AJAX failing

I'm trying to upload files via AJAX. Small files ~10MB are being uploaded successfully.
However, when I try to upload larger files, it fails with the following message:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#.com and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
I'm using Laravel 5 on dreamhost.
I've put debugging messages everywhere, but it seems that my PHP code is not being executed at all. Also, there's no info in error.log either.
I've checked php.ini with following settings:
max_execution_time 30
max_file_uploads 20
post_max_size 500M
upload_max_filesize 500M
Intially, I had mounted /tmp folder at one place which had partition size of 100MB. At that time, the error.log said "modsecurity: input filter failed writing 8192 bytes to temporary file"
So I changed to location of /tmp folder to my home folder in order to remove size restrictions, but not working.
Here is the current behaviour:
File upload shows 100%.
Then the request waits for sometime without causing logs.
After a while, the above mentioned error message is returned.
Let me know which further info is required.
Thank you very much!
For such issues, You should play with few parameters of php.ini.
max_execution_time
max_input_time
post_max_size
upload_max_filesize
Try to keep max_execution_time and max_input_time to ZERO (0).
It won't bound your execution to 30 seconds.
Hope this helps!!

PHP script dies before ftp_get() finishes downloading a file

I know how to download a file from a server using FTP with PHP.
I have a list of files to download from the ftp to an internal storage.
I use ftp_get() to download the list of files,
the first file size is: 126 mb, successfully downloaded to my internal storage.
However the PHP function throws an error 500, and then dies without continuing.
The error I get:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, webmaster#zzz.com and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.
More information about this error may be available in the server error
log.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
Any idea what I should do in order for the function to complete its run successfully?
You need to increase the timeout then. 180 is in seconds, which is 3 minutes. Try setting it to 600. I.e.: FTP_TIMEOUT_SEC, 600 or higher, depending on how much more time is needed. You probably could even try FTP_TIMEOUT_SEC, 0 which I think is NO time limit.
It is already commented for one more question similar to this. Please try this. It should work.
Maybe you exceeded the maximum execution time.
Try to increase it:
https://www.php.net/manual/en/function.set-time-limit.php

Gateway Time-out:The gateway did not receive a timely response from the upstream server

I am sending 300 newsletter at a time with a url, after 2 min it refresh itself again to send next 300 at so on.
But I am getting this error:
Gateway Time-out
The gateway did not receive a timely response from the upstream server
or application.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
I have set max execution to 3600
ini_set('max_execution_time', 3600);
But I am regularly getting same error. Please help me to find out the solution.
I encountered the same problem and I used ini_set('default_socket_timeout', 6000); to fix it.
http://php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout
I encountered the same problem. After i changed my php.ini file
default_socket_timeout = 240
max_execution_time = 240
to fix it.
"Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
This would indicate something is not configured properly on the server.
Can't follow why you think this is a CloudFlare issue right now (from the tag). Are you getting a CloudFlare error message at all?
if the problem is coming from sql sentence, is a server's processing the long query try to optimize the SQL Sentence
I have 18,600,000 rows in my table. TimeOut error was over when I set the TimeOut to 6000 in http.conf after the ServerRoot.

500 Internal Server Error coming when large amount of data is POST to a php file around more than 1 mb

Can anyone explain me why 500 Internal Server Error coming when large amount of data is POST to a php file and the data is around more than 1 mb?
My best guess is that the file is exceeding your configured maximum file size. See http://php.net/manual/en/features.file-upload.php for various discussion and solutions for throwing a prettier error message.
As to increasing those limits, look at "post_max_size" and "upload_max_size" in your .ini file. You'll also likely need to extend the execution time of the script, via "max_input_time" and "max_execution_time".
You can set these in your .ini, or in code as well. See http://blogs.sitepoint.com/upload-large-files-in-php/ for more info.

Categories