Odd PHP issues (not working, handler is set)

HeatherE

Registered
Oct 16, 2013
4
0
1
cPanel Access Level
Root Administrator
Hi all,

Sorry if this is a little nonsensical, I've been debugging this for hours, it's getting late, and I'm more than a little exhausted at this point.

I was having some issues with PHP so I decided to do a rebuild via EasyApache. Following that, PHP has not been working. I do not know if this is something EasyApache has caused or if there is some other configuration issue so I wasn't quite sure where to post.

The odd part is that when I looked in /usr/local/cpanel/logs/error_log, it's not showing errors there, despite throwing 500 errors whenever I try to load a PHP page (HTML pages load fine). I also looked in the root of the website I'm trying to load, no error logs there either.

When I add a rule like:

<FilesMatch "\.(htm|html|php)$">
SetHandler application/x-httpd-php
</FilesMatch>

to the htaccess, then the site displays but does not execute PHP. PHP/Suexec configuration is:

Default PHP Version (.php files) 5
PHP 5 Handler suphp

Apache suEXEC on
Apache Ruid2 off

And I get no errors when I run php -v

I am using a test PHP file which just echoes out some text and exits.

Any thoughts on how to debug this? Where else can I look for useful logs?

Thanks.
 

Sys Admin

Well-Known Member
Apr 29, 2007
67
0
156
cPanel Access Level
Root Administrator
Few things to check first:

- check your php.conf file content at /usr/local/apache/conf/php.conf , Try to reset the handler again via WHM > Configure PHP and suEXEC

- Check your .htaccess files for any conflicting entries.
- 500 errors are usually an indication of a permission related issue, Check and set the correct ownership (user & group) on the files along with the proper permissions set. Since you are using suphp try setting 644 on your .php/.html files and chmod your directories to 755

- Also, You can monitor /usr/local/apache/logs/error_log while testing and browsing your site.

-Some other logs to check if needed:

/usr/local/apache/logs/suphp_log
/usr/local/apache/logs/suexec_log

If you couldn't find anything useful, Then cd into /usr/local/cpanel/logs/easy and review the recent easyapache build log and make sure that it completed successfully, Otherwise I would recommend re-building it once again.
 

HeatherE

Registered
Oct 16, 2013
4
0
1
cPanel Access Level
Root Administrator
Hi, thanks for your help.

I checked php.conf and seems to be the default file (below). I also reset the handler again, through WHM and through the command line, no joy on either front.

Code:
# This file was automatically generated by the Cpanel PHP Configuration system
# If you wish to change the way PHP is being handled by Apache on your system,
# use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
#
# Manual edits of this file will be lost when Apache is updated.


# SuPHP configuration for PHP5
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
<Directory />
    suPHP_AddHandler application/x-httpd-php5
</Directory>

# End of autogenerated PHP configuration.
The .htaccess file which affects the directory where the files I'm trying to access are located only has a couple of rules which I added to temporarily redirect everyone to a maintenance page. I also tried removing those rules and using a blank .htaccess - no joy there either.

However, I've got some possibly useful log output now, from /usr/local/apache/logs/error_log:

Code:
[Thu Oct 17 09:09:25 2013] [error] [client ###.###.###.###] libgcc_s.so.1 must be installed for pthread_cancel to work
[Thu Oct 17 09:09:25 2013] [error] [client ###.###.###.###] Premature end of script headers: index.php
(where ###.###.###.### is my IP address)

So I tried reinstalling libgcc with yum, it appears to be happy that it's installed, reload the page again and the same error comes up.

I'm really not sure where to go from here. I checked the "Max cPanel process memory" setting in WHM and that's on 512MB. I tried another rebuild with basic settings and nothing going there either.

The output in /usr/local/apache/logs/suphp_log just shows "Executing "/home/foo/public_html/test.php" as UID 500 GID 513" over and over. There is no suexec_log (is there meant to be? Is that odd?)

Then in /usr/local/cpanel/logs/easy, there are no files, and in /apache from there I don't see anything that shows any errors, but in /usr/local/cpanel/logs/error_log I now have:

Code:
[2013-10-17 09:23:56 +0100] info [apache_conf_distiller] Missing owner for domain myserver.com, force lookup to root
[2013-10-17 09:24:23 +0100] info [perlinstaller] /root/.cpanel/datastore/Cpanel::Sys::Compiler::test_compile_gcc
[2013-10-17 09:26:27 +0100] info [perlinstaller] /root/.cpanel/datastore/Cpanel::Sys::Compiler::test_compile_gcc
[2013-10-17 09:27:00 +0100] info [perlinstaller] /root/.cpanel/datastore/Cpanel::Sys::Compiler::test_compile_gcc
[2013-10-17 09:31:31 +0100] info [apache_conf_distiller] Missing owner for domain myserver.com, force lookup to root
[2013-10-17 09:31:31 +0100] info [easyapache] Missing owner for domain myserver.com, force lookup to root
[2013-10-17 09:31:31 +0100] info [tailwatchd] Updated chkservd tomcat driver from /usr/local/cpanel/src/chkservd/chkserv.d.
(Where myserver.com is my actual server domain.)

So... aside from reinstalling everything from scratch, any thoughts? I'd rather avoid the hassle of reinstalling everything if possible, but unless there is something glaringly obvious that I'm missing here it seems like the only thing to do?

- - - Updated - - -

Forgot to mention and can't see an edit button on my post - I also tried chmodding my files and directories as you suggested, and no joy there either. HTML files are served fine, PHP files are going splat.
 

HeatherE

Registered
Oct 16, 2013
4
0
1
cPanel Access Level
Root Administrator
Ok I have absolutely no idea what happened, but had just grabbed a full backup of everything preparing to reinstall the lot and it now works again. I am pretty certain that me generating the backup changed nothing, so the frustrating thing is I have no idea what fixed this. So one last thing... is there any log that might tell me why my server is now happy so I know how to fix this if it happens again?? I see my last (graceful) reboot in the error log, and I know after that it wasn't working. After that, nothing on the log.

Aside from that I guess this one is solved, so thanks for your help!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

It's important that you check the Apache error log (/usr/local/apache/logs/error_log) instead of the cPanel error log when you are receiving errors on your website. If this happens again, please report the specific 500 error messages logged to your Apache error log to get a better idea of what is causing the problem.

Thank you.