Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:php_503_error [2014/07/15 19:57]
Michael Armstrong
litespeed_wiki:php_503_error [2015/06/22 03:40]
Gary Duan [6. zend_extension Instead of extension and Vice Versa]
Line 55: Line 55:
 If you find that PHP has crashed (as demonstrated by the process being "​killed by signal"​),​ a core dump will allow you to look further into the cause of the crash. If you find that PHP has crashed (as demonstrated by the process being "​killed by signal"​),​ a core dump will allow you to look further into the cause of the crash.
  
-To enable a core dump, add the environment value ''​LSAPI_ALLOW_CORE_DUMP=1'' ​to your external application settings (WebAdmin console > Configuration > External App). Next time the application crashes, a core dump will be generated. The core file created can usually be found in the directory holding the PHP script affected.+To enable a core dump, add the environment value  
 +  ​LSAPI_ALLOW_CORE_DUMP=1 ​ 
 +to your external application settings (WebAdmin console > Configuration > External App). Next time the application crashes, a core dump will be generated. The core file created can usually be found in the directory holding the PHP script affected.
  
-**Note:** As noted belowopcode caches ​are frequently a cause of PHP crashesIf you find your PHP crashedyou may want to try turning off any opcode caching you have. This is addressed further [[litespeed_wiki:​php_503_error#​opcode_caches_apc_xcache_eaccelerateor|below]].+Your Redhat/​Centos system may already use ABRT(Automatic Bug Reporting Tool) tool to generate core dump files. In this casecore files may be located at /​var/​spool/​abrt/​. ​ ABRT configuration files are normally located at /etc/abrt/ ​Please ensure the setting ​  "​ProcessUnpackaged = yes" in /​etc/​abrt/​abrt-action-save-package-data.conf to enable the core dumpotherwise core file may not be generated even the web server error log says so.  If you want to disable core file dump after the debugging, simply change "​ProcessUnpackaged"​ setting back to "​no"​
  
 +core_pattern is used to specify a core dumpfile pattern name. 
 +  cat /​proc/​sys/​kernel/​core_pattern
 +which shows you the pattern template for the output filename.
 +
 +If the first character of the pattern is a '​|',​ the kernel will treat the rest of the pattern as a command to run.  The core dump will be written to the standard input of that program instead of to a file. 
 +
 +By default, /​proc/​sys/​kernel/​core_pattern contains core string and kernel produces core.* files in crashed process'​s current directory.
 +
 +Abrt’s C/C++ hook overrides this with:
 +  |/​usr/​libexec/​abrt-hook-ccpp %s %c %p %u %g %t e
 +which results in kernel calling abrt-hook-ccpp
 +
 +**Note:** As noted below, opcode caches are frequently a cause of PHP crashes. If you find your PHP crashed, you may want to try turning off any opcode caching you have. This is addressed further [[litespeed_wiki:​php_503_error#​opcode_caches_apc_xcache_eaccelerateor|below]].
 ===== 4. Analyze Core File with GNU Debugger =====  ===== 4. Analyze Core File with GNU Debugger ===== 
  
-GNU Debugger (GDB) uses the syntax ''​gdb <​path/​to/​lsphp/​binary>​ <​path/​to/​core/​file>''​. (Your LSPHP binary can usually be found in ''/​usr/​local/​lsws/​fcgi-bin''​.)+GNU Debugger (GDB) uses the syntax ''​gdb <​path/​to/​lsphp/​binary>​ <​path/​to/​core/​file>''​. (Your LSPHP binary can usually be found in ''/​usr/​local/​lsws/​fcgi-bin''​. ​If you installed LSPHP through LiteSpeed Repository, LSPHP binary file usually locates in ''/​usr/​local/​lsws/​lsphp5x/​lsphp''​('​x'​ means PHP version of '​3'​ '​4'​ '​5'​ or '​6'​) ​)
  
 Once you have opened the core file with GDB, use ''​bt''​ command to print a backtrace of the stack (the steps that the process application took coming to the crash). This will often reveal what caused the crash. Once you have opened the core file with GDB, use ''​bt''​ command to print a backtrace of the stack (the steps that the process application took coming to the crash). This will often reveal what caused the crash.
Line 141: Line 156:
   - Try ''​extension=extension.so''​. "​extension.so"​ is the extension to be loaded, such as pdo.so, or pdo_mysql.so. When you use this syntax, make sure ''​extension_dir''​ is defined in the php.ini with the full path to the directory where all the extensions are found. ​   - Try ''​extension=extension.so''​. "​extension.so"​ is the extension to be loaded, such as pdo.so, or pdo_mysql.so. When you use this syntax, make sure ''​extension_dir''​ is defined in the php.ini with the full path to the directory where all the extensions are found. ​
   - Comment out the ''​extension_dir''​ line to let PHP pick a default.   - Comment out the ''​extension_dir''​ line to let PHP pick a default.
 +
 +===== 7. lsphp process is killed unexpectedly =====
 +
 +when php script is executing, if the process is killed by admin or a process monitoring daemon, it'll simply result 503 error.
 +
 +An Example:
 +
 +A WHM/cPanel server, installed a plugin "​ConfigServer Security & Firewall"​(i.e.,​CSF / LFD), it killed lsphp5 process from time to time and result 503 error.
 +
 +/​etc/​csf/​csf.conf :
 +  # This User Process Tracking option sends an alert if any cPanel user process
 +  # exceeds the time usage set (seconds). To ignore specific processes or users
 +  # use csf.pignore
 +  #
 +  # Set to 0 to disable this feature
 +  PT_USERTIME = "​1800"​
 +  ​
 +so if lsphp5 process has run 1800 seconds(30 minutes), it might be caught by csf and killed. in php suExec Daemon mode or ProcessGroup mode, it's normal that the parent lsphp5 process keep running over 30 minutes. when csf/lfd kill lsphp5 process, it'll leave logs in /​var/​log/​lfd.log,​ like
 +
 +  Jun 19 16:29:16 evo lfd[18304]: *User Processing* PID:18264 Kill:1 User:xxxxx VM:538(MB) EXE:/​usr/​local/​lsws/​fcgi-bin/​lsphp-5.4.42 CMD:lsphp5
 +
 +the time stamp match 503 error in /​usr/​local/​apache/​logs/​error_log:​
 +
 +  2015-06-19 16:​29:​16.370 [NOTICE] [173.245.50.197:​61317-0#​APVH_pingje.org] oops! 503 Service Unavailable
 +
 +the fix:
 +
 +add
 +  pexe:/​usr/​local/​lsws/​fcgi-bin/​lsphp.*
 +to end of /​etc/​csf/​csf.pignore , then restart csf / lfd
 +  # csf -r
 +
 +or in WHM,
 +  Home » Plugins » ConfigServer Security & Firewall
 +  lfd - Login Failure Daemon
 +  "​csf.pignore,​ Process Tracking"​ Edit "lfd ignore file"
 +  append following line
 +  pexe:/​usr/​local/​lsws/​fcgi-bin/​lsphp.*
 +  "​Restart Lfd"
  
 ====== Real World Examples ====== ====== Real World Examples ======