Litespeed - PHP Vhost configuration

Now we know the structure of our virtual host directories, let's go ahead and customise the PHP SuEXEC template to our needs. Once done, adding multiple PHP based virtual hosts to our Litespeed Server takes seconds.

Log into the Administration area and then hover over 'Configurations' and click 'Virtual Host Templates':

You'll be presented with the Virtual Host Templates page which has three pre-defined templates for us: EasyRailsWithSuExec, PHP_SuExec and centralConfigLog:

Click on the PHP_SuEXEC link. You'll notice the layout is very similar to the Server Configuration Page we looked at earlier. The difference is that we can now customise our PHP domains exactly as we want without it affecting anything at a server wide level. Once done, adding a PHP domain takes a couple of seconds.

There isn't a lot to change on the Template Tab - you could rename it or define a custom Listener using a non-standard port but for our needs the default settings are fine.

Move on to the General Tab. Keep in mind the layout of our public_html folder (Virtual Host Layout), we have a few things to change here starting with the Template Settings.

Click on 'edit' and change the Virtual Host Root, Config File, Max Keep-Alive Requests, Smart Keep-Alive and Document Root to the values shown below:

Virtual Host Root               /home/paul/public_html/$VH_NAME/

Config File                          $VH_ROOT/config/$VH_NAME.xml

Max Keep-Alive Requests  1000

Smart Keep-Alive              yes

Document Root                 $VH_ROOT/public/

Before clicking 'save' the Template Settings box would look something like this:

You can start to see the syntax Litespeed uses such as $VH_ROOT. Once the 'Virtual Host Root' is defined, simply refer to it as $VH_ROOT from then on. $VH_NAME has not been set, but this will be the name of the virtual host that will be created later on.

For example, if this website were on a virtual host setting, I would call the virtual host 'usefuljaja.com' and so the Config File would be automatically changed from $VH_NAME.xml to usefuljaja.com.xml.

Click 'save' and move down to the next box called Virtual Host Log. Again, keep in mind the layout discussed before - we want our log files to be in separate folders in each virtual host. This makes for easy migration and analysis.

Use Server's Log             no

File Name                       $VH_ROOT/log/error.log

Log Level                       ERROR

Rolling Size (bytes)         10M

Don't forget to 'save' the changes and move down to the Access Log box. Click 'edit' and change the File Name value (you should be seeing the pattern of how the values are being changed to match our preferred layout):

File Name                      $VH_ROOT/log/access.log

That's all I change in the Access Log configuration but feel free to change the log size and so on.

In the Index Files box, I add index.php to the Index Files value so it reads:

index.html, index.php

You can, of course, change the Use Server Index Files to 'yes' but as you know by now, I like complete control over the virtual hosts and not rely on Server wide settings which I may change later on. Finally, leave the Auto Index to 'No' (hovering over the 'I' symbol gives a good summary as to why).

Move on to the External App tab and click the $VH_NAME_lsphp link. Note the syntax of the link - when a virtual host is created a new lsapi will be created named after your virtual host, i.e. usefuljaja.com.lsphp

The settings I change are as follows:

Max Connections           10

Environment                 PHP_LSAPI_MAX_REQUESTS=500
                                   PHP_LSAPI_CHILDREN=20

Back Log                      50

Instances                     10

Run On Start Up           yes

Max Idle Time               -1

The image below gives a summary of the External Tab values:

At this stage, the only other setting you might want to change is in the Rewrite Tab. If you are planning to use rewrite settings then change the Enable Rewrite value from 'No' to 'Yes'. For even more control, change the value to 'Not Set' and change it for each virtual host. Some sites may want rewrite capabilities and others not.

I hope you are beginning to see the flexibility and control you have over all aspects of your server and the virtual hosts.

That's it, save the setting, 'Apply Changes' and Gracefully Restart the Server.

The sister article to this one details configuring a Ruby on Rails Virtual Host.

PickledOnion

Digg it | del.icio.us | reddit | StumbleUpon

Comments are closed for this article.