php mime is case sensitive

jonium

Verified User
Joined
Nov 10, 2010
Messages
211
Location
Alezio - Lecce- Apulia - South Italy
Hello,
in a server there is a strange situation:
pages with extension .php run correctly while pages .PHP do not.

How may I fix it?


========
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1127.el7.x86_64
Architecture: x86-64

Apache: 2.4.55
PHP (default): 7.2 as php-fpm
PHP (additional): 7.3 as php-fpm
PHP (additional, 3rd): 8.0 as php-fpm
PHP (additional, 4th): 5.6 as php-fpm
 
Last edited:
Hello,

Actually there is nothing strange. For Linux/Unix systems it's a normal behavior. It is only Windows OS is case insensitive in this aspect. There is no simple way to achieve it, you will need to update Apache and PHP-FPM configs. Here is a minimal list of templates to modify:

- /usr/local/directadmin/data/templates/virtual_host2.conf
- /usr/local/directadmin/data/templates/virtual_host2_secure.conf
- /usr/local/directadmin/data/templates/virtual_host2_secure_sub.conf
- /usr/local/directadmin/data/templates/virtual_host2_sub.conf
- /usr/local/directadmin/data/templates/php-fpm.conf

Make sure to read this: https://docs.directadmin.com/webservices/apache/customizing.html to learn on how to customize templates.
 
If I need to do it only for a virtual host, is it right to insert this code in Admin Panel -> Admin Settings -> Customize Httpd Configurations ?


Code:
<Directory "/home/username/public_html">

        <FilesMatch "\.(inc|php|PHP|phtml|phps|php73)$">

            AddHandler "proxy:unix:/usr/local/php73/sockets/username.sock|fcgi://localhost" .inc .php .PHP .phtml .php73

        </FilesMatch>

    <IfModule mod_fcgid.c>

        SuexecUserGroup username username

    </IfModule>

</Directory>

where username is the username of the virtualhost
 
Last edited:
I would suggest that you test it by yourself. DirectAdmin won't save the code if it causes Apache to fail due to a typo. So feel free and test it on your end.

PHP-FPM settings should be changed too as mentioned earlier:

Code:
|*if LIMIT_EXTENSIONS!=""|
security.limit_extensions = |LIMIT_EXTENSIONS|
|*endif|
 
I'm trying another solution, maybe it's more simple:
re-compiled Apache with mod_speling
and add the following to the .htaccess
Code:
# Allow mixed case requests (mod_speling)
CheckSpelling on
CheckCaseOnly on

I think I have to rewrite configs, do I?
 
Hello,

Actually there is nothing strange. For Linux/Unix systems it's a normal behavior. It is only Windows OS is case insensitive in this aspect.
I know it, the problem is with a client who migrated his site from Altervista to us, he has a mechanical sensor sending data to a page (PLC.PHP) and in our environment (DirecAdmin/Apache 2.4) it doesn't work
 
Back
Top