Deploying Django with OpenLiteSpeed (Part 2)

| |

In this part we will be creating virtual host, setup listener and we’ll also test a simple WSGI script to see if openlitespeed and WSGI API are working fine together. Actually the most of the things (creating virtual host, setup listener) in this tutorial are not limited to Django deployment but for all type of deployment in openlitespeed.

I hope you have already logged in to the Web Admin Panel following the steps from previous tutorial. You’ll see something like that.

Great Openlitespeed is up and running. Let’s start creating virtual host for our project. Click on ‘Virtual Hosts’ option in the navigation bar in the left. This will show you the list of virtual hosts available in the server. As we have not created any yet, you can see ‘Example’ virtual host created by Openlitespeed.

Create new Virtual Host

You can understand virtual host as your website. We will need to create virtual host for each website that we deploy in this server. First of all, we’ll create directories for our project that we are going to deploy.

In your terminal, (assuming you are logged in to server) go to the root directory of openlitespeed installation.

$ cd /usr/local/lsws

Now create directory with the name of your choice (In my case “social”) which will be the Virtual Host root directory that stores all files of virtual host.

$ mkdir social
$ mkdir social/{logs,public}

Okay fine, get back to the browser to Web Admin Panel, in the right pane just above the list of virtual you can see “+” sign. Click on that and you’ll get a form to configure virtual host.

The Virtual Host Name are unique identifier for your virtual host. This can be your domain name or just project name. Next field is Virtual Host Root which is root directory for virtual host. It accepts absolute path or a relative path to $SERVER_ROOT.

There are different variables that can be used in different fields, $SERVER_ROOT is path of root directory of openlitespeed(usually /usr/local/lsws), $VH_NAME is virtual host name similarly, $VH_ROOT is virtual host root path.

Config File stores the configuration for the virtual host. The configuration file must be under the $SERVER_ROOT/conf/vhosts/ directory. We’ll keep ‘$SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf’ . Since we are running WSGI app check the “Enable Scripts/ExtApps ” to Yes.

Another option to take care of is “Restrained” check this to Yes for shared environment. This will prevent the website from accessing the files outside the $VH_ROOT directory.

Choose ‘External App Set UID Mode’ as DocRoot UID from the drop-down.

Now save the configuration(check right top pane for Save icon) and again get back to virtual host configuration to specify Document root which is under General tab. Set Document root to $VH_ROOT/public, this is the directory we created in beginning of this tutorial.

In Domain Name field put the domain you want to use for your website. You can add multiple domains in Domain Aliases option.

Create and Assign Listeners

In the left navigation bar, click on the Listeners option. You will find a Default Listener or create a new one with own configuration. We will create a Listener to handle the HTTP request (Port 80) to our server. In this tutorial we won’t be dealing with SSL. For HTTPS you will need to setup listerner for port 443.

Click Add button available at right side above the list of Listeners. You will get a configuration form for listerner. Here is sampleconfiguration you can take as reference. Click the “?” icon in each option to see the detail. We will check Secure option as No since we will not use any SSL.

Finally save the configuration. And view the listerner we just created. You should see something like this. There is the option for Virtual Host Mappings. This will allow to map the virtual host with the listener. Add your Mapping to map the virtual host we created earlier to the domain of your website.

Domains field accept multiple values. You need to separate each domain with comma. I will use “”. Point the domain to your vps by updating DNS records. I have already pointed the domain to server from domain registrar.

You may have noticed a notification in right top side. Since we have made changes in configuration, it will come to effect after restarting the openlitespeed. Click on the “Localhost” menu in Left navigation top, you will get the option for Restart. Click the restart icon and the page will refresh after some time.

We have configured a lot in Openlitespeed. Now we will check the WSGI with a simple python script in the Part 3.


Deploying Django with OpenLiteSpeed (Part 1)

Deploying Django with OpenLiteSpeed (Part 3)

Notify of
Newest Most Voted
Inline Feedbacks
View all comments

hello , this is awesome

[…] out Part 2 for further […]

Would love your thoughts, please comment.x