Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
litespeed_wiki:config:disable_php_override_htaccess [2019/05/09 20:17] Jackson Zhang |
litespeed_wiki:config:disable_php_override_htaccess [2019/05/14 20:19] (current) Lisa Clarke Copyediting |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== How to disable PHP override in .htaccess with LSWS? ====== | + | ====== Disable PHP Override ====== |
- | ''php_value'' and ''php_flag'' can be used in apache configuration or .htaccess to override php.ini settings. However, they are only supported by Apache mod_php handler, which is almost deprecated in most of the control panel systems and is replaced by php-fpm, fastcgi or lsphp. Hence if you place ''php_value'' or ''php_flag'' in .htaccess, Apache should return 500 error (you can check [[https://support.plesk.com/hc/en-us/articles/213409529-Website-hosted-in-Plesk-does-not-work-Invalid-command-php-flag-or-php-value-|a plesk document]] for details). | + | You can disable the PHP override in ''.htaccess'' with LiteSpeed Web Server. |
+ | |||
+ | ''php_value'' and ''php_flag'' can be used in Apache configuration or ''.htaccess'' to override ''php.ini'' settings. However, they are only supported by Apache's ''mod_php'' handler, which is deprecated in most of the control panel systems, having been replaced by php-fpm, fastcgi or lsphp. As a result, if you place ''php_value'' or ''php_flag'' in .htaccess, Apache should return an error. (You can check [[https://support.plesk.com/hc/en-us/articles/213409529-Website-hosted-in-Plesk-does-not-work-Invalid-command-php-flag-or-php-value-|Plesk's documentation]] for details). | ||
+ | |||
+ | You could see any one of the following errors: | ||
500 internal server error | 500 internal server error | ||
- | |||
- | or: | ||
503 Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration. | 503 Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration. | ||
The following error can be found in the domain error log in Domains > example.com > Logs: | The following error can be found in the domain error log in Domains > example.com > Logs: | ||
/var/www/vhosts/example.com/httpdocs/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration | /var/www/vhosts/example.com/httpdocs/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration | ||
- | |||
- | or: | ||
/var/www/vhosts/example.com/httpdocs/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration | /var/www/vhosts/example.com/httpdocs/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration | ||
- | |||
- | or: | ||
/var/www/vhosts/example.com/httpdocs/.htaccess: RewriteRule: bad flag delimiters | /var/www/vhosts/example.com/httpdocs/.htaccess: RewriteRule: bad flag delimiters | ||
- | |||
- | or: | ||
/var/www/vhosts/example.com/public_html/.htaccess: Invalid command 'suPHP_ConfigPath', perhaps misspelled or defined by a module not included in the server configuration. | /var/www/vhosts/example.com/public_html/.htaccess: Invalid command 'suPHP_ConfigPath', perhaps misspelled or defined by a module not included in the server configuration. | ||
| | ||
- | While LSWS will use lsphp, which is actually supported ''php_value'' and ''php_flag'' usage in .htaccess and LSWS won't return 500 at all. This give LSWS more error tolerant than Apache. | + | LiteSpeed Web Server uses lsphp, which supports ''php_value'' and ''php_flag'' usage in .htaccess. You can use these and LSWS will not return a 500 error. LSWS is more tolerant than Apache of these PHP overrides. |
- | In some cases, you may want to disable such php override in .htaccess for LiteSpeed as well. There is a dedicate Apache directive ''DisablePhpOverride htaccess'' can be used at server level httpd.conf to achieve this. | + | In some cases, you may want to disable such PHP overrides in .htaccess for LiteSpeed as well. There is a dedicated Apache directive ''DisablePhpOverride htaccess'', which can be used at the server level ''httpd.conf'' to achieve this. |
- | For example, place the following to the global include file such as ''pre_main_global.conf'' for cpanel: | + | For example, on Plesk, create a file named ''DisablePhpOverrideLiteSpeed.conf'' in the following directory, depending upon your system: |
+ | |||
+ | * CentOS: ''/etc/httpd/conf.d/'' | ||
+ | * Debian: ''/etc/apache2/conf.d/'' | ||
+ | * Ubuntu: ''/etc/apache2/conf-enabled'' | ||
+ | |||
+ | This ''DisablePhpOverrideLiteSpeed.conf'' file should contain the following: | ||
<IfModule LiteSpeed> | <IfModule LiteSpeed> | ||
DisablePhpOverride htaccess | DisablePhpOverride htaccess | ||
</IfModule> | </IfModule> | ||
- | |||
- |