I set up a local development server with multiple PHP versions following the information here https://openlitespeed.org/kb/setup-per-directory-file-php/
However when using specific PHP versions this way I had problems with pages loading - missing CSS and very slow speed. Developer tools in Firefox showed errors like this:
The stylesheet was not loaded because its MIME type, "text/html", is not "text/css"
even though the mime type was specified correctly as text/css in the HTML:
<link rel="stylesheet" type="text/css" href="assets/css/styles.css" media="all">
The problem seems to be caused by using "Force MIME Type" to set the PHP handler. All files are parsed through this and sent as text/html regardless of what they are. This results in the incorrect MIME type error and the slow performance as the server tries to parse images, CSS, Javascript and everything else as PHP.
To solve this, instead of using "Force MIME Type", I have used the "MIME Type" field and set it to:
application/x-httpd-lsphp70 php phar
This only parses php and phar files as php (as the specified version), and serves the rest following normal MIME rules. Extra file types could be added if required.
Hopefully this is useful and maybe the documentation can be amended or a note added once someone more knowledgable has done more testing.
However when using specific PHP versions this way I had problems with pages loading - missing CSS and very slow speed. Developer tools in Firefox showed errors like this:
The stylesheet was not loaded because its MIME type, "text/html", is not "text/css"
even though the mime type was specified correctly as text/css in the HTML:
<link rel="stylesheet" type="text/css" href="assets/css/styles.css" media="all">
The problem seems to be caused by using "Force MIME Type" to set the PHP handler. All files are parsed through this and sent as text/html regardless of what they are. This results in the incorrect MIME type error and the slow performance as the server tries to parse images, CSS, Javascript and everything else as PHP.
To solve this, instead of using "Force MIME Type", I have used the "MIME Type" field and set it to:
application/x-httpd-lsphp70 php phar
This only parses php and phar files as php (as the specified version), and serves the rest following normal MIME rules. Extra file types could be added if required.
Hopefully this is useful and maybe the documentation can be amended or a note added once someone more knowledgable has done more testing.