Help:Set Up VHost-Level PHP

From OpenLiteSpeed
Jump to: navigation, search

By default, all virtual hosts use the server-level external applications and script handlers. You can, however, set up virtual host-specific PHP settings by creating virtual host-level external applications and script handlers that link to custom-built PHP executables. This will allow you to set up different PHP versions and configurations for different virtual hosts (and can also lead to the ability to use multiple PHP versions on one virtual host). (For more on how to build a custom PHP, see our article on the subject. For more about external applications and script handlers, see our article on the default PHP settings.)

Add a virtual host-level external application

(WebAdmin console => Configuration => Virtual Hosts => your vhost => External Application => Add => Type => LSAPI)

The most important setting here is to set Command to the location of the PHP build you wish to use. (All copies of PHP are automatically copied to $SERVER_HOME/fcgi-bin/ if created using OpenLiteSpeed's PHP Build utility.

Lsphp5-vhost-settings.png

Add a virtual host-level script handler for PHP

(WebAdmin console => Configuration => Virtual Hosts => your vhost => Script Handler => Add

The script handler settings tell OpenLiteSpeed where to send files of a certain suffix. Here you will want to specify the suffix that PHP scripts in this virtual host have and tell them to be sent to the external application you just created. (For this reason it is necessary to create the external application first.)

Lsphp5-scripthandler-vhost.png

Now you have set that this virtual host will send its .php files to PHP 5.4.17 instead of any other PHP build. Congratulations.