Litespeed web server + Forbidden: PHP engine is disable

Recently upgraded from Apache (runing suPHP as a PHP handler) to Litespeed.

Everything worked as they should, as Litespeed is a direct drop-in replacement for apache.

However, there is one issue I ran into with Magento.

Bunch of Magento installs weren’t working, even brand new installs are broken. After doing some checking, it appears some important CSS and JS files were being blocked from loading. If you try to load a CSS or JS file in the /pub/static folder, it will fail and return the following message.

Forbidden: PHP engine is disable

After speaking with LiteSpeed support, it appears Magento the previous setup (Apache + suPHP) was working because it somehow ignore the

php_flag engine 0

flags set in the /pub/static/.htaccess file.

There are two ways to fix this.

  1. Comment out both of the flags in the /pub/static/.htaccess for your Magento install.
  2. Add the following code in your Litespeed configuration

<IfModule LiteSpeed>

CacheRoot /home/lscache/

php_admin_flag engine on

</IfModule>

If you are running cPanel, then you just have to goto WHM -> Apache Configuration -> Include Editor -> Pre Main Include -> All Versions