Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:php:per-directory-php [2018/02/19 19:35]
Jackson Zhang
litespeed_wiki:php:per-directory-php [2018/09/17 17:30] (current)
Michael Alegre [Set Different PHP Per Virtual Host]
Line 1: Line 1:
-====== Enable ​per directory ​PHP in LSWS native mode ====== +====== Enable ​Per-Directory ​PHP in LSWS (Native) ​====== 
-This wiki is to explain how to set per directory ​PHP and it is only applicable for LSWs native mode and doesn'​t fit when you use control panel or apache ​configuration ​mode.+It is possible ​to use different versions of PHP in different directories,​ but only with a LiteSpeed Web Server (native) installation. It is not applicable for control panel or Apache ​configuration ​modes.
  
 +===== Set Different PHP Per Virtual Host =====
 +When you use LSWS (native) without Apache configuration,​ you can define the PHP version through a PHP handler for each virtual host. To do so, you normally define multiple server-level external PHP apps, and then assign different handlers at the server level and virtual host level. If no virtual host level hander is defined, the virtual host will inherit the server-level PHP configuration.
  
-===== Set different PHP per virtual host ===== +====Example==== 
-When you use LSWS native without apache configuration,​ Normally you can define PHP version through PHP handler for each virtual host. To do so, you normally define multi-server level PHPs external apps and assign different handler ​at the server level and virtual host level. If no virtual host level hander defined, the virtual host will heritage server level PHP configuration. +We set these external apps at the server level: ​''​lsphp54''​''​lsphp55''​''​lsphp56''​''​lsphp70''​''​lsphp71''​''​lsphp72''​.
- +
-For example, we set external apps at server level:​lsphp54,​ lsphp55, lsphp56, lsphp70, lsphp71, lsphp72.+
  
 {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-1.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-1.png?​800 |}}
  
-The lsphp70 external app looks like the following, the rest are similar to it:+The configuration for the lsphp70 external app looks like thisand the rest are similar to it:
 {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-external-apps-1.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-external-apps-1.png?​800 |}}
  
-At the server level, we defined ​lsphp71 as default handler to handle .php and .php5. ​+At the server level, we define ​lsphp71 as the default handler to handle ​''​.php'' ​and ''​.php5''​
 {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-handlers-default-2.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-handlers-default-2.png?​800 |}}
  
-The virtual host will hesitate ​the above server default handler lsphp71 unless overridden. ​The following is an example to override the php version to lsphp56 for that virtual host.+The virtual host will inherit ​the above server default handler ​''​lsphp71'' ​unless overridden. ​Here we override the PHP version to ''​lsphp56'' ​for that virtual host:
 {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-handlers-vh-3.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-handlers-vh-3.png?​800 |}}
  
-===== Set different ​PHP per directory within one virtual host ===== +===== Set Different ​PHP Per Directory Within One Virtual Host ===== 
-The above wiki explains ​how to set different ​PHP for each virtual host, but if you would like to set different ​PHP within a virtual host, most likely per-directory basis, in addition to the above, you will set more handler in server level "​script handler"​, then use .htaccess to change the php version ​+We saw how to set different ​PHPs for each virtual host, but if you would like to set different ​PHPs //within// a virtual host, there is some additional configuration. Most likely ​you'll want to do this on a per-directory basis, ​so in addition to the above steps, you will set more handlers at the server level under **Script Handler**and then use ''​.htaccess'' ​to change the PHP version
  
-Add handlers to server level: in addition to the exiting ​.php and .php5 suffix, add .php54, .php55, .php56, .php70, .php71, .php71, .php72+Add handlers to server level: in addition to the existing ''​.php'' ​and ''​.php5'' ​suffix, add ''​.php54''​''​.php55''​''​.php56''​''​.php70''​''​.php71''​''​.php71''​and ''​.php72''​.
 {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-handlers-2.png?​800 |}} {{ :​litespeed_wiki:​php:​lsws-native-per-directory-php-handlers-2.png?​800 |}}
  
-On virtual host DEFAULT, we have changed it to use lsphp56.+On virtual host DEFAULT, we have changed it to use ''​lsphp56''​.
  
-Under the sub directory /sub1/, it will use lsphp56 as well. To change it to use different version lsphp72, ​  ''​vi sub1/​.htaccess''​+Under the sub directory ​''​/sub1/''​, it will use lsphp56 as well. To change it to use different version lsphp72, ​  ''​vi sub1/​.htaccess''​
  
   ForceType application/​x-httpd-php72   ForceType application/​x-httpd-php72
Line 42: Line 42:
   ForceType application/​x-httpd-php71   ForceType application/​x-httpd-php71
  
-===== Set different ​php.ini ​per directory ​===== +===== Set Different ​php.ini ​Per Directory ​===== 
-The above instruction ​will set different ​php version ​by using server level defined external apps, hence only global php.ini set for each version. ​ To define different php.ini per directory, you will set all server level external apps at virtual host level with different names and add PHPRC environment variable to define ​php.ini for each version under that virtual host. +The above instructions ​will set different ​PHP versions ​by using server-level-defined external apps, hence only the global ​''​php.ini''​ is set for each version. ​ To define ​different ​''​php.ini'' ​per directory, you will set all server level external apps at the virtual host level with different names and add the ''​PHPRC'' ​environment variable ​definition ​to ''​php.ini'' ​for each version under that virtual host. 
  • Admin
  • Last modified: 2018/02/19 19:35
  • by Jackson Zhang