Edit Note
Notebook (optional)
-- No Notebook --
Cyberpael
Title
Content (Markdown supported)
Cyberpanel allows deployment of Django application easily. This guide will take you through a step by step guide on how this can be achieved. At the end, you will know 1. How to Host a Django app on Cyberpanel with Openlitespeed. 2. Install Multiple Versions of Python for your application. 3. Configure Virtual host settings for Openlitespeed be able to serve your Django app. We shall deploy our Django app on Cyberpanel - on the URL: https://djp.lintsawa.com/ In this guide I will be using Almalinux 8. Step 1: Installing Python. Here we shall install the same python version as we used on localhost. Installing Python First. Current Python Version on Almalinux is 3.6 and I want to use 3.8 as that is what I used for the project. ========================= Install Dependencies. Ubuntu ---------- $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl Almalinux ---------- yum -y install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel mysql-devel pkgconfig libpq-devel Install Development packages. yum -y groupinstall "Development Tools" Step 2: Download and Install pyenv Pyenv will be used to allows us manage multiple versions of python and easy installation of any version we need. Will be using this to install python 3.8.20 curl https://pyenv.run | bash Enable pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc Confirm pyenv is working by typing commands below. pyenv pyenv install --list - To show available versions pyenv install 3.8.20 - To install the selected version. All done. pyenv versions Step 3: Installing wsgi ================ curl -O https://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-2.1.tgz tar xf wsgi-lsapi-2.1.tgz ls cd wsgi-lsapi-2.1/ ls Here we need to compile wsgi with our new python version hence we switch to this version. pyenv global 3.8.20 python3 --version ls Switch our python version from 3.6 to the newly installed one. pyenv global 3.8.20 pyenv versions python3 --version Build wsgi with the new python version. python3 ./configure.py make cp lswsgi /usr/local/lsws/fcgi-bin/ cd /usr/local/lsws/fcgi-bin/ Step 4: Create a website on Cyberpanel. ============================== Upload our files to public_html folder Navigate via SSH to cd /home/djp.lintsawa.com/public_html/ Create and activate virtual env python3 -m venv /home/djp.lintsawa.com/public_html/ source /home/djp.lintsawa.com/public_html/bin/activate Navigate to your projects directory. cd portfolio-website-main/ ls cat requirements.txt pip install -r requirements.txt python manage.py migrate python manage.py collectstatic Go back to Cyberpanel dashboard > Websites > List Website > Manage > Configurations >vHost and Add the context below to vHost section of your domain. Add Context. ================= context / { type appserver location /home/djp.lintsawa.com/public_html/portfolio-website-main binPath /usr/local/lsws/fcgi-bin/lswsgi appType wsgi startupFile Portfolio/wsgi.py envType 1 env LS_PYTHONBIN=/home/djp.lintsawa.com/public_html/bin/python3 } All Done. Reload your site should be working well. In case of Errors: ========== tail -f /usr/local/lsws/logs/stderr.log Done.
Categories (comma separated)
Tags (comma separated, without #)
Attachments (max 5 files)
Save
Cancel
Preview