500 Server Error

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
JOhnMag4u
-


Joined: 16 Jul 2007
Posts: 7
Location: Brodheadsville, PA

PostPosted: Wed May 02, 2012 7:06 pm    Post subject: 500 Server Error Reply with quote

I have recently put together a PHP script (performing thousands of MySQL queries) which will take about 45 seconds for my server to run. After exactly 30 seconds the page times out saying: Error 500 Internal Server Error.

I have increased all the values in my php.ini (yes I ran php info to make sure I was editing the correct php.ini file). I also increased the Abyss timeout from the default 30 to 60.

I then saw I was getting errors in my CGI error log (I had PHP set to CGI, not FastCGI). The errors did not tell me much that was helpful. I read through this forum and found some people with this problem had luck switch to fastCGI. I tried both versions of local fastCGI and I get the following in my error log:

Code:
02/May/2012:13:49:05 -0400   SUID: 0   PUID: 0   process_shutdown_now()
02/May/2012:13:49:14 -0400   SUID: 0   PUID: 0   RUID: 0   URI:    Reading 0 bytes failed = The process cannot access the file because it is being used by another process.
02/May/2012:13:49:14 -0400   SUID: 0   PUID: 0   RUID: 0   URI:    timeout-header2!
02/May/2012:13:49:44 -0400   SUID: 0   PUID: 0   RUID: 1   URI: /newtekconversion/convertToOpenCart.php   Reading 8 bytes failed = The process cannot access the file because it is being used by another process.


I also tried decreasing the Abyss Timeout setting to 5 seconds, but it still timed out after 30. Finally I increased all php.ini timeout and memory limitations AND the Abyss Timeout setting to a ridiculous amount of time, something like 3 days, and still have a 500 error after 30 seconds exactly. I am using YSlow and Firebug in FireFox to time the page load.

Any help and/or recommendations would be greatly appreciated!

FYI, I am running: Abyss Web Server X2 (v 2.7), PHP Version 5.2.7, MySQL 4.1.22, and Windows XP Pro

Code:
<?php
//Is called to test if an item is already in the catalog based on the item_no

function ifexist($item_no){
   
   include 'dbconfig2.php';
   
   $sqlSelectItemNo = "SELECT `sku` FROM `product` WHERE `sku` = '" . $item_no . "'";
   $resultSelectItemNo = mysql_query($sqlSelectItemNo) or die(mysql_error());
   $numofresults = mysql_num_rows($resultSelectItemNo);
   
   mysql_close();
   
   return $numofresults;
}

include 'dbconfig.php';
$sqlProducts = 'SELECT * FROM `newteksource` WHERE `publish` = "1"';
$resultProducts = mysql_query($sqlProducts) or die(mysql_error());
while($rowProduct = mysql_fetch_array($resultProducts)){
   echo ifexist($rowProduct['item_no']);
}
mysql_close();


?>


In the above code, if I comment out:
Code:
$resultSelectItemNo = mysql_query($sqlSelectItemNo) or die(mysql_error());

Everything loads nice and fast.
_________________
JohnMag4u.com
Back to top View user's profile Send private message Visit poster's website AIM Address
jxxaxxy
-


Joined: 11 Nov 2010
Posts: 27

PostPosted: Wed May 02, 2012 10:20 pm    Post subject: Reply with quote

I ran into this problem with the Anti-hacking Protection. Or at least I think it is the same situation.

When the script runs there is either an error or removed function from php all together due to updates/new version.

So somewhere it is causing errors or thinking there is an error and the anti-hack kicks in and blocks your ip for a certain amount of time.

I went back and forth with abyss in emails about this with really no answer for it.

Try disabling the anti-hack feature and see if your 500 issue goes away.

Also if you do have a 500 error see if you can access the page with another pc (another pc meaning different network as yours will be blocked). If it does access the page from another pc then it has to do with the auto ban of the anti-hacking software.

I really didn't want to disable it but I can't always control what people put up for websites or there coding skills. It was a major headache!!!!!
Back to top View user's profile Send private message
JOhnMag4u
-


Joined: 16 Jul 2007
Posts: 7
Location: Brodheadsville, PA

PostPosted: Wed May 02, 2012 10:51 pm    Post subject: Reply with quote

Thanks for your feedback. I did read a few people talking about the anti-hacking feature causing a similar problem. Unfortunately, I already had anti-hacking turned off, so this shouldn't be causing the issue.
_________________
JohnMag4u.com
Back to top View user's profile Send private message Visit poster's website AIM Address
Toasty
-


Joined: 21 Feb 2008
Posts: 295
Location: Chicago, IL

PostPosted: Sat Jun 16, 2012 3:38 am    Post subject: Reply with quote

I've had similar issues. Apache does the same thing in many instances. Your best bet it to run it CLI, like this:

Start > Run > type "cmd"


c:\phppath\php c:\path\to\php.file



This eliminates the web server, this assumes that you don't require it being web accessible. If you do, revise your query.

Finally, you can make your script progressive. The inserts (I assume) you're doing should have an auto-increment column. Use this to determine where the script left off, and refresh the browser to continue the inserts.
_________________
Portfolio: Robert Lerner
Back to top View user's profile Send private message Visit poster's website
chelsearason
-


Joined: 21 Jun 2012
Posts: 1

PostPosted: Sat Jun 23, 2012 4:43 am    Post subject: Reply with quote

Is there any way to make it work with the anti-hacking on? I mean I want it but I don't like to sacrifice security.
Back to top View user's profile Send private message
aprelium-support
-


Joined: 20 Feb 2009
Posts: 356

PostPosted: Thu Jun 28, 2012 2:05 pm    Post subject: Reply with quote

chelsearason wrote:
Is there any way to make it work with the anti-hacking on? I mean I want it but I don't like to sacrifice security.


This behavior has nothing to do with anti-hacking. Moreover, in version 2.8 things should run more smoothly as the software is more tolerant with faultly FastCGI processes (or those which timeout.)
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group