These forums are read-only!
Abrupt Failure of Wordpress - solved?
  • I had my Wordpress blogs happily spinning along, when suddenly they all failed, claiming that my PHP installation appears to be missing MySQL. However, I've got MySQL installed and running. I can get in there and access the databases and tables via SQL and all that, so it's functioning. I've accessed it using the Wordpress username, and called up the Wordpress database, just to make sure those weren't messed up somehow.

    Any clues on what to do to fix it? I've tried soft and hard reboots. I even tried a reinstall of Wordpress, on the theory that some PHP file might have gotten contaminated, but that did nothing. I am puzzled that, even though I have MySQL going, it somehow won't connect with Wordpress.

    UPDATE: Following hints from stubblechin and artagesw, I tried reinstalling the PHP modules that relate to MySQL. This had no effect. I tried stopping and restarting MySQL and Apache, without any apparent effect.

    However, later on, for reasons that elude my feeble grasp, the blogs all started working again. I'm wondering whether something needed time to get started? Or caching on my browser? I'm pleased to be back up, but I would really like to track this down.

    I'll certainly post more as I unravel this mystery. Thanks for your help, folks! I really appreciate it.
  • Can you show us the output of running the following command? sudo grep -r extension /etc/php*/ | grep mysql

  • Did your PHP-MySQL extension get disabled somehow? Check the output of phpinfo() to make sure the mysql extension is loading properly.
  • @stubblechin:

    /etc/php5/conf.d/mysql.ini:extension=mysql.so
    /etc/php5/conf.d/mysqli.ini:extension=mysqli.so
    /etc/php5/conf.d/pdo_mysql.ini:extension=pdo_mysql.so
    /etc/php5/apache2/conf.d/mysql.ini:extension=mysql.so
    /etc/php5/apache2/conf.d/mysqli.ini:extension=mysqli.so
    /etc/php5/apache2/conf.d/pdo_mysql.ini:extension=pdo_mysql.so

    @artagesw:

    AFAIK, the extensions are still there. At least, I get a bunch of stuff about MySQL being used, various values of variables in MySQL, and so on. Anything in particular I should be looking for?
  • Baruch, what happens if you run php on the command line and try to connect to your WP database? Use either php -a Or php-cgi -a Then type: <?php mysql_connect('localhost', 'wp_user', 'wp_pass'); mysql_select_db('wp_db_name'); ?> Replacing my fake values with real ones of course. If you get any output, show us. If you get no output, the mystery deepens, because that means everything should be working fine.

    You can ctrl-c to get back out of the interactive mode.

  • Er, the Vanilla forum over-escaped my code. The ampersand-lt-semicolon is obviously supposed to be a less-than sign...

  • Ah, I just noticed your update! Great, glad you're back up and running.

  • @stubblechin:

    Funny you should mention it - when I try your idea, I'm told "command not found". And yet, when I access phpinfo(), I get a nice display (using a .php page to browse). In other words, I seem not to have it from the command line, but my browser now knows it's there.

    I'm back to waving a dead chicken over it, hoping it will work...
  • What about with one of these? php5-cgi -a or php5 -a The name of the php binary can vary depending on version, cgi or not, etc. I'd just type php and hit tab a couple of times until a likely candidate was autocompleted.

  • Hi, Stubblechin:

    Nothing. Neither php, php5, php-cgi, or php5-cgi worked. I tried the autocomplete (hit the tab) and it found nothing to complete. I tried it as my username, and also as root. I tried it on both my slices, the one I use, and the one I play around with. Nothing. And yet, when I try it on my local computers, I get a response (one's running the same OS, Gutsy, so it's apparently not an Ubuntu problem).

    I think this is more interesting than the original problem, because in fact I've got PHP working on my slice - Wordpress is, at least for the moment, functioning. So - *why* is it functioning?? Or, why isn't the command line PHP working?
  • Search me, Baruch...I'm stumped. Maybe because PHP is integrated in mod_php there's no php executable that can be reached on the command line? I use php with fastcgi so I have the following executables: php-cgi and php5-cgi. One is a symlink to the other, so both are teh same exact thing.

  • Thanks for all your help, Stubblechin. This is a mystery, but... I think it's something along the lines you suggest. Something may have happened to screw up the access to the files from the command line (that is, php no longer shows up in the path directories for some reason), but the Wordpress files can access it for some reason. Maybe it's a direct link to the executable, instead of just the name and assume it's in the path somewhere.

    I'm going to see if I can track it down anyway, and definitely put something up if I can find an answer. Thanks again for your help.
  • mod-php in apache requires no command line php executable. It is entirely possible to use that without installing any command line php versions. I'm not an ubuntu user, but there may be separate packages for the various php binaries.
  • Yeah, Ubuntu doesn't package the command line interpreter with the php5 standard packages... to get the CLI:
    apt-get install php5-cli
    I always include it in my default build. (I also include the php-pear package in my Slice-n-Dice build) ... Hmm, do you have locking enabled or disabled in mySQL? Did you change any of the buffer, stack or packet sizes in my.cnf from the defaults?
  • Hi, Gadget:

    I didn't realize that you had to add the cli by hand. I had assumed it was installed by default. In fact, it *is* installed on my home boxes, for some reason. I'll put it up on my slices, just for fun. And to save what's left of my sanity.

    I haven't played at all with the MySQL - I left all the defaults there. Remember, I'm a noob who can only afford to destroy one thing at a time.

    Thanks for your helpful ideas and hints. I do appreciate them.
  • Yeah, I make that assumption too. It *should* just be there! Funny thing, the install of Ubuntu on my bashemup box has it too, but I did load it from the CD.. Being a Slackware (the mother of all distros - it's big, bad, and yet, somehow just works) user for so long, I find that Ubuntu is taxing my sanity too, so you're not alone there! 8-)

    Hmm, since you left the mySQL settings alone, it begs the next question: How big is your Slice memory? The default settings for mySQL are set to allow quite an incredible amount of resource consumption (would be an issue on a 256, maybe on a 512 if you're heavily loaded) and if mySQL ends up swapping or something, WordPress could very well have troubles... I find WordPress a tad touchy that way sometimes. Sadly, WP works only with mySQL, so getting engaged to a lesser known daemon isn't even a real option (although it has been done by others). Are you running just one blog, or more than one? If you're running multiple blogs, WordPress-MU (multi-user) might be something to consider, from the viewpoint of database efficiency and transaction handling..
  • @Gadget:

    I'm running a few blogs, but it's on a 512. I haven't noticed any memory problems at all. I've seen here how MySQL can go wild and eat up your disk and RAM, and if I see that happening, I'll take a look. I'm learning the details of PHP for now; once that's done I'll get more familiar with MySQL.

    I'm OK with using MySQL. I wonder, though, why WP is so tightly coupled to one DB. Seems they could fix it to run more generically, allowing people to choose. Well, if I'm not happy with them I can always demand a refund...