How to Set Up a Virtual Host-Specific PHP

How Can We Help?
< Back
You are here:


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 => 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.

Add a Virtual Host-Level Script Handler For PHP

(WebAdmin console => 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.)


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.