Troubleshooting “Cannot get media type from ‘x-mapp-php5′” Warning in Apache PHP Configuration


5 views

When working with PHP files served through Apache in an aliased directory, you might encounter this warning in your error logs:

[warn] Cannot get media type from 'x-mapp-php5'

This typically occurs when Apache attempts to determine the MIME type for PHP files but encounters an unrecognized handler specification.

The problem stems from Apache's MIME type resolution mechanism when processing PHP files. The warning suggests Apache is falling back to default type detection because:

  • The handler declaration might be incomplete or ambiguous
  • MIME type mappings aren't properly configured for PHP files
  • The aliased directory might need special configuration

Here's a more robust way to configure PHP handling in your httpd.conf or virtual host file:


    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
    AddType application/x-httpd-php .php
    AddHandler application/x-httpd-php .php


Alias /smartersoftware/ "/path/to/your/directory"

Notice these critical changes from the original setup:

1. Replaced deprecated Order/Allow directives with Require all granted
2. Added both AddType and AddHandler directives
3. Removed the FilesMatch block in favor of directory-specific settings

If the warning persists, try these additional approaches:

Option 1: Explicit MIME type declaration

AddType application/x-httpd-php5 .php
AddHandler x-httpd-php5 .php

Option 2: Using SetHandler with full path


    SetHandler application/x-httpd-php

After making changes, always:

sudo apachectl configtest
sudo systemctl restart apache2

Check your error logs for improvements:

tail -f /var/log/apache2/error.log

The combined AddType and AddHandler directives ensure Apache properly associates .php files with both the correct MIME type and processing handler. The directory-specific configuration prevents conflicts with other PHP handlers that might be loaded globally.


When working with PHP in an aliased directory on Apache, you might encounter this warning in your error logs:

[warn] Cannot get media type from 'x-mapp-php5'

This typically occurs when Apache tries to determine the MIME type for PHP files but finds conflicting or incomplete handler definitions.

The core issue stems from how PHP handlers are defined. In your httpd.conf, you have:

<Directory "<dir with broken php>">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
Alias /smartersoftware/ "<broken dir>"
<FilesMatch \\.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Here are three approaches to resolve this:

Option 1: Explicit MIME Type Definition

AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php

Option 2: Using SetHandler in Directory Context

<Directory "<your directory>">
    SetHandler application/x-httpd-php
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
</Directory>

Option 3: PHP Module Configuration

<IfModule mod_php5.c>
    AddType application/x-httpd-php .php
    AddHandler application/x-httpd-php .php
</IfModule>

After making changes, test with:

sudo apachectl configtest
sudo apachectl graceful

Create a test PHP file with:

<?php
phpinfo();
?>

The warning should no longer appear in your logs, and PHP should execute correctly.

If you're using PHP-FPM, consider this alternative configuration:

<FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>