Score:1

What determines the name of Apache PHP Handlers?

de flag

When configuring an Apache server to use a Handler to run PHP code, I'm familiar with adding a line similar to below in httpd.conf or .htaccess:

AddHandler application/x-httpd-php81 .php

This tells Apache to use the named handler to interpret .php files. It's straightforward enough, but on different hosting services, and locally, I'm seeing differences in the specific name used for the handler, which is complicating the configuration of my environments. As a specific example, on a hosted web server the line has to contain the PHP version, as above, but with a locally installed Apache server, and PHP downloaded from php.net, the name is more general:

AddHandler application/x-httpd-php .php

In other situations I've seen some other variations, such as:

AddHandler application/x-httpd-ea-php81___lsphp

What dictates what names are supported/required? Searching online hasn't turned up any source of valid names, only config examples for different hosting environments. Is there any simple way I can influence the names expected on my local install?

in flag
The documentation seems pretty clear to me. https://httpd.apache.org/docs/2.4/handler.html
frumious avatar
de flag
@GeraldSchneider Agreed, what it says is clear. I can't see that it says where the real-world valid names for PHP handlers actually come from, though.
Score:0
vn flag

Most often, you'll see variants that specify the PHP version on shared hosts where there are multiple PHP versions installed; this is because some users may be running web sites that break with newer versions, and so each virtual host has a PHP handler defined that works with that site. The ea- versions in particular are provided with the EasyApache suite, used (in my limited experience) with hosts providing access through cPanel. The specific names quite often are local to the hosts, you would have to check with your hosting group to see which PHP versions they have installed and what they've called them.

frumious avatar
de flag
Thanks - I suppose my question is less about "in what situations are they different" or "why do people do this", but more "what have the hosting companies technically done to make it happen", and, importantly "how do I do it myself so that I don't have to keep changing my .htaccess file locally"...
tsc_chazz avatar
vn flag
The hosting companies that have `ea-` in the name have installed cPanel (which is a paid framework) and the associated EasyApache 4 package. Others have installed different PHP versions and provided aliases that distinguish them so they can have multiple versions available at once, then have provided those aliases as handlers. If you have to do this, the EasyApache package might be your best bet, being as it's simplest.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.