LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 08-11-2011, 10:34 AM   #1
vockleya
Member
 
Registered: Aug 2009
Posts: 87

Rep: Reputation: 16
Apache custom 500 error not showing after php syntax error


I have Apache set up to display custom error pages for the most common http errors. All of them are working fine except the 500 error. When a php script crashes, I should get a 500 error, and I do, just the wrong one. Apache's standard 500 error message shows, instead of my custom one.

When I go directly to the error page from a browser, it shows up just fine.

All of the error pages are created in a php file, to give more useful information than a static page. Could this be why it doesn't show up when a script dies because of a syntax error?

Last edited by vockleya; 08-11-2011 at 10:35 AM.
 
Old 08-11-2011, 11:34 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,895

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

I guess you use something like:
Code:
ErrorDocument 500 /path/to/error500.php
Are you sure it's not your browser cache?
 
Old 08-11-2011, 01:38 PM   #3
vockleya
Member
 
Registered: Aug 2009
Posts: 87

Original Poster
Rep: Reputation: 16
That is what I am using in my virtual server config file.

I just realized that I am actually not getting the Apache error page, I am getting a blank page. There is no html being sent to the browser. Chrome shows a generic built-in 500 error and firefox and safari show a blank page.
 
Old 08-11-2011, 03:45 PM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,895

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

A blank page means php errors. Check the apache error log to see if you find anything.
You can also set
Code:
display_errors = On
in php.ini, so you see the eventual errors in your browser (need to restart apache)
 
Old 08-11-2011, 04:13 PM   #5
vockleya
Member
 
Registered: Aug 2009
Posts: 87

Original Poster
Rep: Reputation: 16
There are errors, but not on the 500 error page. It works fine when I go straight to it from a browser. It's when another php script errors out and apache tries to send the error page that it doesn't work.
 
Old 08-11-2011, 04:20 PM   #6
vockleya
Member
 
Registered: Aug 2009
Posts: 87

Original Poster
Rep: Reputation: 16
When I turn display_errors on, I see the php syntax error, but nothing about the custom error page. It's like apache isn't even trying to load the page.
 
Old 08-11-2011, 04:31 PM   #7
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Kubuntu
Posts: 1,190

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Why do you thing that?
Quote:
When a php script crashes, I should get a 500 error
Code 500 is not for errors in php script. If you want to catch these errors use "set_error_handler()" and "set_exception_handler()" functions.

Last edited by eSelix; 08-11-2011 at 04:34 PM.
 
Old 08-11-2011, 04:42 PM   #8
vockleya
Member
 
Registered: Aug 2009
Posts: 87

Original Poster
Rep: Reputation: 16
Oh. I thought that was the error because that is the one that Chrome shows when a php script has an error. Is that just what Chrome shows when it gets a page with no data?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected '@' in php code minipro Programming 1 06-14-2011 04:33 AM
Parse error: syntax error (install_admin_menu.php line 2) mike24078 Programming 10 04-08-2010 08:34 AM
Unable to start apache on CentOS Linux with error Starting httpd: Syntax error on lin pkumar2533 Linux - Newbie 9 08-26-2009 07:48 AM
php / MySQL: You have an error in your SQL syntax error FirstBorn Programming 6 12-31-2008 05:46 PM


All times are GMT -5. The time now is 08:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration