Deploying Django with OpenLiteSpeed (Part 5)

| |

We have uploaded our project in the last part of tutorial. We’ll now create virtual environment and use the requirements.txt for installation of package. Finally we will have our project LIVE after few more configurations.

Log on to the VPS using terminal before proceeding.

Create Virtual Environment

First let’s install virtualenv package in our server. virtualenv is a tool to create isolated Python environments.

$ pip3 install virtualenv

We’ll create virtual environment inside the virtual host folder(/usr/local/lsws/social here). Run following command:

$ virtualenv /usr/local/lsws/social

And activate the environment using :

$ source /usr/local/lsws/social/bin/activate

Check if python loaded from virtual environment

$ which python

Install Packages from requirements.txt

Navigate to root directory of the project

$ cd /usr/local/lsws/social/public

Now we’ll install all the packages in the requirements.txt file. Run this command in terminal.

$ pip3 install -r requirements.txt

Finally we need to install psycopg2 library as adaptor between Python and Postgesql Database.

$ pip3 install psycopg2

Final Touch

We are almost finished the setup part and our site will be Live soon. Now lets edit the Context configuration. Open the Web Admin Panel in browser and Navigate to Virtual Hosts > “Your Virtual Host” > Context > “Your context” . Click on “pen” icon to edit the configuration.

We had set the Startup File to “”. Change it to point the location of file of Django project. file is located in same folder as by default. This path is relative to application root directory. Also in Environment we’ll add some variables like PYTHONPATH for setting up with virtual environment.

Startup File : social/

Collect static files

$ python collectstatic

And the Final step, Create admin super user

$ python migrate
$ python createsuperuser

Great! you are all set up and your site is already LIVE. Visit http://YOUR_DOMAIN in the browser


Deploying Django with OpenLiteSpeed (Part 4)

Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments

[…] Alright!! we are ready for finals steps. We will install the required packages and finally completely deploy django with openlitespeed in next article( Part 5 ). […]

Would love your thoughts, please comment.x