LINUX Webserver stopped serving up PHP pages after update

Discussion in 'Apache' started by Strictly Software, May 21, 2010.

  1. #1
    I did an update on my LINUX server earlier tonight with the following packages

    apache2.2-common apache2-mpm-worker apache2 usermin libapt-pkg-perl apt-show-versions webmin webmin-virtual-server

    Afterwards my Wordpress sites stopped working and all PHP files are being served as file attachments with a content type:

    of application/x-httpd-php

    Chrome shows the basic html,css,js but IE and FF just download the file as if it were an attachment so the server has stopped parsing PHP correctly.

    I read a few articles of similar problems and I have tried adding the following to all the php.ini files I can find in /etc/php5/cli and /etc/php5/cgi but it doesn't seem
    to solve anything. Maybe I am doing it in the wrong place OR there are other ini / conf files I don't know aboiut. How can I check whether the system is setup correctly and what has changed to cause this?

    Also I tried removing all my htaccess rules as I thought it was an issue with my caching system but that didn't work either

    My htacess file has the following in it

    <FilesMatch "\.(gif|png|jpg|css|js|swf|flv|ogg)$">
    ExpiresActive On
    ExpiresDefault "access plus 1 weeks"
    FileETag none
    </FilesMatch>

    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
    </IfModule>

    # BEGIN supercache
    <IfModule mod_mime.c>
    <FilesMatch "\.html\.gz$">
    ForceType text/html
    FileETag None
    </FilesMatch>
    AddEncoding gzip .gz
    AddType text/html .gz
    </IfModule>
    <IfModule mod_deflate.c>
    SetEnvIfNoCase Request_URI \.gz$ no-gzip
    </IfModule>
    <IfModule mod_headers.c>
    Header set Vary "Accept-Encoding, Cookie"
    Header set Cache-Control 'max-age=300, must-revalidate'
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html A300
    </IfModule>
    # END supercache
    # END WPSuperCache

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress


    I am not a sysadmin so not really sure what the problem is only that it started after the update.

    Any help would be much appreciated.
     
    Strictly Software, May 21, 2010 IP
  2. crashus

    crashus Active Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #2
    You lack of php type in the apache config

    Be sure to have LoadModule libphp5.so (its usually goes with full path)

    and these in your httpd.conf:

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
     
    crashus, May 22, 2010 IP
  3. Strictly Software

    Strictly Software Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes I had to add the following to the ini file


    AddHandler application/x-httpd-php .php
    LoadModule php5_module modules/libphp5.so

    as well as re-install libapache2-mod-php5

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

    Why this all disappeared from my server after the upgrade I have no idea? Site had been up and running okay for months.

    Thanks for your help
     
    Strictly Software, May 23, 2010 IP
  4. crashus

    crashus Active Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Glad you've managed to work this out
     
    crashus, May 23, 2010 IP