messed up apache2-php5 installation

Discussion in 'HOWTO-Related Questions' started by klonos, Jan 24, 2009.

  1. klonos

    klonos New Member

    Hello everyone and a happy 2009 (this is my first post for this year)

    After upgrading some of my virtual users/perfect server setups to 8.10 I've somehow managed to mess my apache configuration. I've googled around and tried a couple of things but it didn't get the job done :(

    First things first:

    I cannot get php to work properly and all php files offer download instead of open/run in browsers. I need some help to troubleshoot this one.

    As I said system is upgraded to latest 8.10, apache is:

    Apache/2.2.9 (Ubuntu) mod_python/3.3.1 Python/2.5.2 mod_ruby/1.2.6 Ruby/1.8.7(2008-08-11) mod_ssl/2.2.9 OpenSSL/0.9.8g

    my apache.conf:

    Code:
    ServerRoot "/etc/apache2"
    
    LockFile /var/lock/apache2/accept.lock
    
    PidFile ${APACHE_PID_FILE}
    
    Timeout 300
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 15
    
    <IfModule mpm_prefork_module>
        StartServers          5
        MinSpareServers       5
        MaxSpareServers      10
        MaxClients          150
        MaxRequestsPerChild   0
    </IfModule>
    
    <IfModule mpm_worker_module>
        StartServers          2
        MaxClients          150
        MinSpareThreads      25
        MaxSpareThreads      75 
        ThreadsPerChild      25
        MaxRequestsPerChild   0
    </IfModule>
    
    # These need to be set in /etc/apache2/envvars
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    
    AccessFileName .htaccess
    
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>
    
    DefaultType text/plain
    
    HostnameLookups Off
    
    ErrorLog /var/log/apache2/error.log
    
    LogLevel warn
    
    # Include module configuration:
    Include /etc/apache2/mods-enabled/*.load
    Include /etc/apache2/mods-enabled/*.conf
    
    # Include all the user configurations:
    Include /etc/apache2/httpd.conf
    
    # Include ports listing
    Include /etc/apache2/ports.conf
    
    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    
    # Define an access log for VirtualHosts that don't define their own logfile
    CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
    
    # Include generic snippets of statements
    Include /etc/apache2/conf.d/
    
    # Include the virtual host configurations:
    Include /etc/apache2/sites-enabled/
    
    ...is default, (I simply removed most of the comments here just to make it short)

    I have defaults in httpd.conf (empty) and my ports.conf:

    Code:
    # If you just change the port or add more ports here, you will likely also
    # have to change the VirtualHost statement in
    # /etc/apache2/sites-enabled/000-default
    
    NameVirtualHost *:80
    Listen 80
    
    <IfModule mod_ssl.c>
        # SSL name based virtual hosts are not yet supported, therefore no
        # NameVirtualHost statement here
        Listen 443
    </IfModule>
    also my mime.types:

    Code:
    ...
    application/x-httpd-php                phtml pht php
    application/x-httpd-php-source            phps
    application/x-httpd-php3            php3
    application/x-httpd-php3-preprocessed        php3p
    application/x-httpd-php4            php4
    ...
    I have not disabled php globally as the perfect server setup instructs, since I have no ISPconfig installed and the servers only serve one domain

    What might I be overlooking here?

    Thanx in advance.
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Can you try
    Code:
    a2enmod php5
    /etc/init.d/apache2 restart
    ?
     
  3. klonos

    klonos New Member

    Solved this one! Read on to see how...

    trying 'a2enmod php5' spits:

    Code:
    ERROR: Module php5 does not exist!
    Thought I've missed something, so I tried (re)installing libapache2-mod-php5 plus some more php5 stuff:

    Code:
    apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell php5-snmp php5-sqlite php5-xmlrpc php5-xsl
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    libapache2-mod-php5 is already the newest version.
    php5 is already the newest version.
    php5-common is already the newest version.
    php5-curl is already the newest version.
    php5-dev is already the newest version.
    php5-gd is already the newest version.
    php5-imagick is already the newest version.
    php5-mcrypt is already the newest version.
    php5-memcache is already the newest version.
    php5-mhash is already the newest version.
    php5-mysql is already the newest version.
    php5-pspell is already the newest version.
    php5-snmp is already the newest version.
    php5-sqlite is already the newest version.
    php5-xmlrpc is already the newest version.
    php5-xsl is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
    It turns out (as I knew beforehand) they were already installed.

    This is what my mods-available & mods-enabled look like:

    Code:
    ls -l /etc/apache2/mods-available
    total 352
    -rw-r--r-- 1 root root  332 2008-09-19 16:41 actions.conf
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 actions.load
    -rw-r--r-- 1 root root  815 2008-09-19 16:41 alias.conf
    -rw-r--r-- 1 root root   62 2008-09-19 16:41 alias.load
    -rw-r--r-- 1 root root   60 2008-09-19 16:41 asis.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 auth_basic.load
    -rw-r--r-- 1 root root   74 2008-09-19 16:41 auth_digest.load
    -rw-r--r-- 1 root root   72 2008-06-09 11:02 auth_mysql.load
    -rw-r--r-- 1 root root   74 2008-09-19 16:41 authn_alias.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 authn_anon.load
    -rw-r--r-- 1 root root   85 2008-09-19 16:41 authn_dbd.load
    -rw-r--r-- 1 root root   70 2008-09-19 16:41 authn_dbm.load
    -rw-r--r-- 1 root root   78 2008-09-19 16:41 authn_default.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 authn_file.load
    -rw-r--r-- 1 root root   90 2008-09-19 16:41 authnz_ldap.load
    -rw-r--r-- 1 root root   70 2008-09-19 16:41 authz_dbm.load
    -rw-r--r-- 1 root root   78 2008-09-19 16:41 authz_default.load
    -rw-r--r-- 1 root root   82 2008-09-19 16:41 authz_groupfile.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 authz_host.load
    -rw-r--r-- 1 root root   74 2008-09-19 16:41 authz_owner.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 authz_user.load
    -rw-r--r-- 1 root root 3265 2008-09-19 16:41 autoindex.conf
    -rw-r--r-- 1 root root   70 2008-09-19 16:41 autoindex.load
    -rw-r--r-- 1 root root   62 2008-09-19 16:41 cache.load
    -rw-r--r-- 1 root root   70 2008-09-19 16:41 cern_meta.load
    -rw-r--r-- 1 root root   68 2008-09-19 16:41 cgid.conf
    -rw-r--r-- 1 root root   60 2008-09-19 16:41 cgid.load
    -rw-r--r-- 1 root root   58 2008-09-19 16:41 cgi.load
    -rw-r--r-- 1 root root   76 2008-09-19 16:41 charset_lite.load
    -rw-r--r-- 1 root root   36 2008-09-19 16:41 dav_fs.conf
    -rw-r--r-- 1 root root   79 2008-09-19 16:41 dav_fs.load
    -rw-r--r-- 1 root root   58 2008-09-19 16:41 dav.load
    -rw-r--r-- 1 root root   68 2008-09-19 16:41 dav_lock.load
    -rw-r--r-- 1 root root   58 2008-09-19 16:41 dbd.load
    -rw-r--r-- 1 root root  107 2008-09-19 16:41 deflate.conf
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 deflate.load
    -rw-r--r-- 1 root root  122 2008-09-19 16:41 dir.conf
    -rw-r--r-- 1 root root   58 2008-09-19 16:41 dir.load
    -rw-r--r-- 1 root root  604 2008-09-19 16:41 disk_cache.conf
    -rw-r--r-- 1 root root   89 2008-09-19 16:41 disk_cache.load
    -rw-r--r-- 1 root root   64 2008-09-19 16:41 dump_io.load
    -rw-r--r-- 1 root root   58 2008-09-19 16:41 env.load
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 expires.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 ext_filter.load
    -rw-r--r-- 1 root root   89 2008-09-19 16:41 file_cache.load
    -rw-r--r-- 1 root root   64 2008-09-19 16:41 filter.load
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 headers.load
    -rw-r--r-- 1 root root   62 2008-09-19 16:41 ident.load
    -rw-r--r-- 1 root root   68 2008-09-19 16:41 imagemap.load
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 include.load
    -rw-r--r-- 1 root root  420 2008-09-19 16:41 info.conf
    -rw-r--r-- 1 root root   60 2008-09-19 16:41 info.load
    -rw-r--r-- 1 root root   60 2008-09-19 16:41 ldap.load
    -rw-r--r-- 1 root root   76 2008-09-19 16:41 log_forensic.load
    -rw-r--r-- 1 root root  185 2008-09-19 16:41 mem_cache.conf
    -rw-r--r-- 1 root root   87 2008-09-19 16:41 mem_cache.load
    -rw-r--r-- 1 root root 6298 2008-09-19 16:41 mime.conf
    -rw-r--r-- 1 root root   60 2008-09-19 16:41 mime.load
    -rw-r--r-- 1 root root   89 2008-09-19 16:41 mime_magic.conf
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 mime_magic.load
    -rw-r--r-- 1 root root  666 2008-09-19 16:41 negotiation.conf
    -rw-r--r-- 1 root root   74 2008-09-19 16:41 negotiation.load
    -rw-r--r-- 1 root root   87 2008-09-19 16:41 proxy_ajp.load
    -rw-r--r-- 1 root root   97 2008-09-19 16:41 proxy_balancer.load
    -rw-r--r-- 1 root root  589 2008-09-19 16:41 proxy.conf
    -rw-r--r-- 1 root root   95 2008-09-19 16:41 proxy_connect.load
    -rw-r--r-- 1 root root   87 2008-09-19 16:41 proxy_ftp.load
    -rw-r--r-- 1 root root   89 2008-09-19 16:41 proxy_http.load
    -rw-r--r-- 1 root root   62 2008-09-19 16:41 proxy.load
    -rw-r--r-- 1 root root   64 2008-05-03 08:17 python.load
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 rewrite.load
    -rw-r--r-- 1 root root   60 2008-01-23 21:33 ruby.load
    -rw-r--r-- 1 root root 1122 2008-09-19 16:41 setenvif.conf
    -rw-r--r-- 1 root root   68 2008-09-19 16:41 setenvif.load
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 speling.load
    -rw-r--r-- 1 root root 2412 2008-09-19 16:41 ssl.conf
    -rw-r--r-- 1 root root   58 2008-09-19 16:41 ssl.load
    -rw-r--r-- 1 root root  398 2008-09-19 16:41 status.conf
    -rw-r--r-- 1 root root   64 2008-09-19 16:41 status.load
    -rw-r--r-- 1 root root   72 2008-09-19 16:41 substitute.load
    -rw-r--r-- 1 root root   64 2008-09-19 16:41 suexec.load
    -rw-r--r-- 1 root root   70 2008-09-19 16:41 unique_id.load
    -rw-r--r-- 1 root root  604 2008-09-19 16:41 userdir.conf
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 userdir.load
    -rw-r--r-- 1 root root   70 2008-09-19 16:41 usertrack.load
    -rw-r--r-- 1 root root   66 2008-09-19 16:41 version.load
    -rw-r--r-- 1 root root   74 2008-09-19 16:41 vhost_alias.load
    
    Code:
    ls -l /etc/apache2/mods-enabled
    total 4
    lrwxrwxrwx 1 root root  28 2009-01-24 02:56 alias.conf -> ../mods-available/alias.conf
    lrwxrwxrwx 1 root root  28 2009-01-24 02:56 alias.load -> ../mods-available/alias.load
    lrwxrwxrwx 1 root root  33 2009-01-24 02:56 auth_basic.load -> ../mods-available/auth_basic.load
    lrwxrwxrwx 1 root root  33 2009-01-24 02:57 auth_mysql.load -> ../mods-available/auth_mysql.load
    lrwxrwxrwx 1 root root  33 2009-01-24 02:57 authn_file.load -> ../mods-available/authn_file.load
    lrwxrwxrwx 1 root root  36 2009-01-24 02:57 authz_default.load -> ../mods-available/authz_default.load
    lrwxrwxrwx 1 root root  38 2009-01-24 02:57 authz_groupfile.load -> ../mods-available/authz_groupfile.load
    lrwxrwxrwx 1 root root  33 2009-01-24 02:57 authz_host.load -> ../mods-available/authz_host.load
    lrwxrwxrwx 1 root root  33 2009-01-24 02:57 authz_user.load -> ../mods-available/authz_user.load
    lrwxrwxrwx 1 root root  32 2009-01-24 02:57 autoindex.conf -> ../mods-available/autoindex.conf
    lrwxrwxrwx 1 root root  32 2009-01-24 02:57 autoindex.load -> ../mods-available/autoindex.load
    lrwxrwxrwx 1 root root  26 2009-01-24 03:31 cgi.load -> ../mods-available/cgi.load
    lrwxrwxrwx 1 root root  30 2009-01-24 02:57 deflate.conf -> ../mods-available/deflate.conf
    lrwxrwxrwx 1 root root  30 2009-01-24 02:57 deflate.load -> ../mods-available/deflate.load
    lrwxrwxrwx 1 root root  26 2009-01-24 02:57 dir.conf -> ../mods-available/dir.conf
    lrwxrwxrwx 1 root root  26 2009-01-24 02:57 dir.load -> ../mods-available/dir.load
    lrwxrwxrwx 1 root root  26 2009-01-24 02:57 env.load -> ../mods-available/env.load
    lrwxrwxrwx 1 root root  30 2009-01-24 03:30 include.load -> ../mods-available/include.load
    lrwxrwxrwx 1 root root  27 2009-01-24 02:57 mime.conf -> ../mods-available/mime.conf
    lrwxrwxrwx 1 root root  27 2009-01-24 02:57 mime.load -> ../mods-available/mime.load
    lrwxrwxrwx 1 root root  34 2009-01-24 02:57 negotiation.conf -> ../mods-available/negotiation.conf
    lrwxrwxrwx 1 root root  34 2009-01-24 02:57 negotiation.load -> ../mods-available/negotiation.load
    -rw-r--r-- 1 root root 133 2009-01-24 03:44 php5.conf
    lrwxrwxrwx 1 root root  29 2009-01-24 03:31 python.load -> ../mods-available/python.load
    lrwxrwxrwx 1 root root  30 2009-01-24 03:30 rewrite.load -> ../mods-available/rewrite.load
    lrwxrwxrwx 1 root root  31 2009-01-24 02:57 setenvif.conf -> ../mods-available/setenvif.conf
    lrwxrwxrwx 1 root root  31 2009-01-24 02:57 setenvif.load -> ../mods-available/setenvif.load
    lrwxrwxrwx 1 root root  26 2009-01-24 03:03 ssl.conf -> ../mods-available/ssl.conf
    lrwxrwxrwx 1 root root  26 2009-01-24 03:03 ssl.load -> ../mods-available/ssl.load
    lrwxrwxrwx 1 root root  29 2009-01-24 02:57 status.conf -> ../mods-available/status.conf
    lrwxrwxrwx 1 root root  29 2009-01-24 02:57 status.load -> ../mods-available/status.load
    lrwxrwxrwx 1 root root  29 2009-01-24 03:30 suexec.load -> ../mods-available/suexec.load
    ...well the php5.conf seemed to be the only file in mods-enabled (all others ware symlinks to their corresponding file in /etc/apache2/mods-available) and I believe it got there because I followed some advice on editing /etc/apache2/mods-enabled/php5.conf.

    I believe that all a2enmod does is simply create those symlinks in mods-enabled for each mod you choose to enable and that a2dismod simply removes symlinks pointing to mods-available once you choose to remove a module.

    So, I've moved php5.conf in mods-available and tried 'a2enmod php5' once again. Same 'Module php5 does not exist!' error (perhaps that php5.load file missing?). Then, I created a symlink pointing to it in mods-enabled myself and tried reloading apache2.

    Code:
    mv /etc/apache2/mods-enabled/php5.conf  /etc/apache2/mods-available
    
    cd /etc/apache2/mods-enabled
    ln -s ../mods-available/php5.conf php5.conf
    Anyway, here is what my php5.conf looks like (I think it is all defaults):

    Code:
    <IfModule mod_php5.c>
      AddType application/x-httpd-php .php .phtml .php3
      AddType application/x-httpd-php-source .phps
    </IfModule>
    
    I don't know if there's supposed to be a php5.load file as well in mods-available, but there is none. Other modules' .load files seem to load .so files that reside in /usr/lib/apache2/modules/ and in there resides a libphp5.so(GBP 4.69) file. So, I became really creative and created a 'php.load' file in mods-available:

    Code:
    LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
    Then as if it was magic:

    Code:
    a2enmod php5
    Enabling module php5.
    Run '/etc/init.d/apache2 restart' to activate new configuration!
    ... and finally all worked fine! Yhey!!

    Hope this will help people having the same issue in the future.
     

Share This Page