Results 1 to 5 of 5

Thread: How to force PHP 5.6 for files without extensions

  1. #1
    Join Date
    Oct 2003
    Posts
    175

    How to force PHP 5.6 for files without extensions

    This server runs PHP 7.2 and 5.6.
    Code:
    build options | grep php
    PHP (default): 7.2 as mod_php
    PHP (additional): 5.6 as php-fpm

    One of the sites running PHP 5.6 has this in its .htaccess:
    Code:
    <FilesMatch "^[^.]+$"> 
      ForceType application/x-httpd-php 
    </FilesMatch>
    This is so that URLs like https://domain.tld/index are served by PHP. It has worked fine for many years.

    Unfortunately, after a recent rebuild of PHP, these files are now served by PHP 7 and the site is getting errors like this:
    Code:
    [Thu Jun 13 09:44:25.728763 2019] [php7:error] [pid 17672] [client x.x.x.x:57610] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_pconnect()
    If I create a file "phpinfo.php", phpinfo() shows php 5.6, however if I put phpinfo() in a file called just phpinfo (no .php extension), it shows php 7.2.

    How can I force files without an extension to be served by php 5.6?

  2. #2
    Join Date
    Aug 2006
    Location
    LT, EU
    Posts
    8,125
    application/x-httpd-php isn't a handler of PHP-FPM 5.6, that's why it defaults to the mod_php.
    Martynas Bendorius
    MB Martynas IT. Professional server management company. Official DirectAdmin, CloudLinux, LiteSpeed and Comodo partners.

  3. #3
    Join Date
    Oct 2003
    Posts
    175
    Do you know what I can use instead?

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,724

  5. #5
    Join Date
    Oct 2003
    Posts
    175
    Quote Originally Posted by zEitEr View Post
    Thanks. I ended up updating the site to run on PHP 7, which was long overdue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •