Apache server or PHP issues randomly appearing

No sure how to title this topic… but basically on several different websites on several different servers recently, the websites break. Some of them the index.php file is downloaded and some of them just report an error which is:
[Tue Jan 03 09:50:52 2017] [error] [client 217.155.157.22] PHP Fatal error: Class ‘PDO’ not found in /home/myaccount/public_html/lhc_caststn/ezcomponents/Database/src/handler.php on line 23

(the filepath above varies depending on the CMS, but its basically saying it cant find the PDO class).

phpinfo() shows that no PHP modules are loaded hence the above PDO error. The php compile arguments show with no PDO or something, including with no MySQL etc. Like no modules are loaded.

So what I do to fix this, is change the "“PHP script execution mode” to CGI then it works, then I change it back to FCGId and it works again. I wonder if some configuration of Apache has changed, and resaving it in Website options fixes it.

This has happened on several sites on different servers at random times. I was fixing it as it happens until it happened today on a site the second time. So I am concerned it will keep happening.

Thanks

What OS and did you update/upgrade your php?

It was just a yum update. PHP nor apache was updated. On Centos 6. Several different servers. I am not sure if its related to the yum update because I rolled back on one server due to this issue, and it happened again.

So its still happening on different servers, at random times. not often but now and again.

Can you run this command “yum repolist enabled” and post the results.

[root@server ~]# yum repolist enabled Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: mirrors.vooservers.com * epel: epel.check-update.co.uk * extras: mirrors.vooservers.com * updates: mirrors.vooservers.com repo id repo name status base CentOS-6 - Base 5,062 epel Extra Packages for Enterprise Linux 6 - i386 9,949 extras CentOS-6 - Extras 39 longview Longview Repo 34 mod-pagespeed mod-pagespeed 6 newrelic New Relic packages for Enterprise Linux 5 - i386 138 updates CentOS-6 - Updates 552 varnish-3.0 Varnish 3.0 for Enterprise Linux 5 - i386 48 virtualmin RHEL/CentOS/Scientific 6 - i386 - Virtualmin 146 virtualmin-universal Virtualmin Distribution Neutral Packages 77 repolist: 16,051

Longview Repo is from my hosting provider linode.
I could probably get rid of newrelic and varnish, not using them now.

I asked you for this because its never good idea to leave any repo on rampage during “yum update”. It could be that some of the repos on your list overwrites Centos original files and causing a lot of problems. I remember little more than a year i was testing Vm on Centos 6 and one night i was tired and left Epel enabled. Once “yum update” was over i was left with unusable server.

If you need all those repos then its smart to limit what each repo can update, e.g. Epel to update only fail2ban. Right now i can think of two things:

  1. Use “yum history list all” or for specific software “yum history list [software]” (e.g. “yum history list httpd”) to check the updates. For specific update use “yum history info #” where # is ID of the update you want to see. Foe example, if you see Epel updated httpd you can rollback the updates with “yum downgrade <software.version>”.

  2. Check if PDO is installed and enabled.

BE SURE TO MAKE OFF-SERVER BACKUP and if you still have a problem post Apache/System log files. There must be something about your problem.

Any other ideas? I cant see it being related to the unused repos, I have removed them anyway.

Its as if the apache server config is changed or something. because in the past when I had config issues, I would switch from FCGI to CGI and it fixed it, and I can switch back. Same happens here. Or I can disable Apache and then reenable, that will fix it. I know that resets the config back to what virtualmin creates. Its just quicker switching to CGI and back.

So it happened again this morning/overnight on 4 different websites. All 4 websites are on different servers. All 4 websites are the same websites its happened to previously. And they all reported it this morning. I do not know if they all went down the same time though.

To summarise, its as if PHP is loaded with no mysql, pdo etc etc support. phpinfo() shows that no PHP modules are loaded hence the above PDO error. The php compile arguments show with no PDO, mysql etc. Like no modules are loaded.

I just dont know how this would happen on its own while the server is running and no changes made, and to only a few sites (the same sites so far). Switching to CGI then fixes it, PHP is once again loaded with all the correct modules.

If I use a web sniffer to get the header, on the page thats broken (sometimes it downloads the index file) it says:

Content-Type: application/x-httpd-php

But when I fix it as above it says:

Content-Type: text/html; charset=UTF-8

Here is the server config when not working

SuexecUserGroup "#515" "#511" ServerName mydomain.co.uk DocumentRoot /home/mydomain/public_html ErrorLog /var/log/virtualmin/mydomain.co.uk_error_log CustomLog /var/log/virtualmin/mydomain.co.uk_access_log combined ScriptAlias /cgi-bin/ /home/mydomain/cgi-bin/ DirectoryIndex index.html index.htm index.php index.php4 index.php5 Options -Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch FCGIWrapper /home/mydomain/fcgi-bin/php5.fcgi .php FCGIWrapper /home/mydomain/fcgi-bin/php5.fcgi .php5 FCGIWrapper /home/mydomain/fcgi-bin/php5.4.fcgi .php5.4 AddType application/x-httpd-php .php AddType application/x-httpd-php5 .php5 allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch RewriteEngine on Alias /pipermail /var/lib/mailman/archives/public

here is the config after changing to CGI and then back again to FCGId so there are some differences at the bottom, and in the middle its added AddHandler

SuexecUserGroup “#515” “#511
ServerName mydomain.co.uk
DocumentRoot /home/mydomain/public_html
ErrorLog /var/log/virtualmin/mydomain.co.uk_error_log
CustomLog /var/log/virtualmin/mydomain.co.uk_access_log combined
ScriptAlias /cgi-bin/ /home/mydomain/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/mydomain/public_html>
Options -Indexes +IncludesNOEXEC +SymLinksifOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php5.4
FCGIWrapper /home/mydomain/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/mydomain/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/mydomain/fcgi-bin/php5.4.fcgi .php5.4

<Directory /home/mydomain/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch

RewriteEngine on
Alias /pipermail /var/lib/mailman/archives/public
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.4
php_admin_value engine Off
IPCCommTimeout 31
FcgidMaxRequestLen 1073741824

well,

AddHandler fcgid-script…

for sure you need that for FCGID…

then, please check your php.conf for

# SetHandler application/x-httpd-php

as you can see that “SetHandler” must be commented out…

Thank you, but I think the main concern is why is it changing? One minute a site works, then it doesn’t. Switching to CGI and back to FCGId results in a different server configuration for when it was not working.

So its as if something is changing the conf which breaks it, and switching to FCGi and back resets it back? Just a hunch.

what mpm are you loading with LoadModule… ? that’s an odd behavior…