Saturday, 22 May 2010

Problems with LINUX, Apache and PHP

LINUX Apache Server stopped serving up PHP pages

When I logged into my hosted LINUX web server earlier tonight I was met with a message saying I should install a number of new packages. I usually ignore things like this until it gets to a point where someone forces me to do purely for the reasons which will become obvious shortly.

The packages were the following:

  • apache2.2-common
  • apache2-mpm-worker
  • apache2
  • usermin
  • libapt-pkg-perl
  • apt-show-versions
  • webmin
  • webmin-virtual-server
I have no idea what most of them do but they had been sitting around for a long time waiting for me to install them and tonight was the night. Shortly afterwards I notices that my Wordpress sites had stopped working and all the PHP files were being served as file attachments with a content type of application/x-httpd-php instead of being parsed, executed and then delivered as text/html.

At first I thought it was something to do with the SQL performance tweaks I was doing but I soon remembered about the updates and I went off hunting the web for a solution.

It's nights like these that make me wish I was back doing carpet fitting, finishing the day at 3 pm and then going down the pub again rather than spending Friday night scratching my head wondering what the fuck I had done to bring down my website at 3 am.

To cap off the nightmare I spent ages writing a detailed message to post on an APACHE web forum only for my session to timeout and then for the site to refuse to log me in and then block me for failing 5 login attempts in a row. Obviously I couldn't get back my message so I was properly pissed off.

For some reason APACHE had stopped recognising PHP file extensions and I still don't know what had happened under the covers but after a long hunt I came across the solution.

The libapache2-mod-php5 module had somehow disappeared so I had to re-install it with the following lines:

sudo apt-get purge libapache2-mod-php5
sudo apt-get install libapache2-mod-php5
sudo a2enmod php5
sudo /etc/init.d/apache2 restart

I also added the following two lines to /etc/php5/apache2/php.ini
AddHandler application/x-httpd-php .php
LoadModule php5_module modules/libphp5.so

I then cleared my browser cache and low and behold my site came back.

Maybe this info might come in handy for anyone else about to upgrade packages on their server or serve as a reminder of what happens when you try to behave like a sysadmin and have no idea what your actually doing.

Labels: , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home