Setting Up Django with CyberPanel: A Beginner-Friendly Guide
In this tutorial, we’ll guide you through the process of setting up Django with CyberPanel, a web hosting control panel that makes managing your website and applications simple. Django is a powerful web framework for building web applications using Python. By integrating Django with CyberPanel, you can efficiently host and manage your Django projects.
Prerequisites:
- A server with CyberPanel installed You can install CyberPanel on your server by following their official documentation.
- Basic knowledge of Python and Django.
- SSH access to your server.
Step 1: Create a Django project
First, log into your server via SSH. Once logged in, navigate to the directory where you want to build your Django project. Then, create a new virtual environment for your project to keep your dependencies isolated.
cd /path/to/your/directory
python3 -m venv myprojectenv
Activate the virtual environment:
source myprojectenv/bin/activate
Now, install Django using pip:
pip install django
Create a new Django project:
django-admin startproject myproject
Navigate into your project directory:
cd myproject
Step 2: Configure CyberPanel
Log in to your CyberPanel control panel.
- Navigate to the “Website” section.
- Click on “Create Website”.
- Fill the required details like domain name, username and password.
- For “Type”, select “Python”.
- Under “Script Handler”, select “WsgiHandler”.
- Set “document root” to the directory where your Django project resides.
Click “Create Website” to finish setting up your website.
Step 3: Configure Django settings
Open your Django project’s settings.py file:
nano /path/to/your/directory/myproject/settings.py
Update the ALLOWED_HOSTS setting to include your domain name:
ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com']
Step 4: Configure WSGI File
Create a new WSGI file for your Django project:
nano /home/yourusername/yourdomain.com/public_wsgi.py
Paste the following content into the file, replacing “myproject” with your project name:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
application = get_wsgi_application()
Save and close the file.
Step 5: Restart CyberPanel
After completing the configuration, restart CyberPanel to apply the changes.
Step 6: Test your Django application
Visit your domain in a web browser to see if your Django application is running correctly If everything is set up correctly, you should see the default Django welcome page.
Congratulations! You have successfully set up Django with CyberPanel. You can now start building your Django web application and deploy it easily.
Thank you for reading. If you find something wrong or better ways to do it, let me know in the comments below.
If you like the post, hit the 👏 button below so that others may find it useful. You can follow me on GitHub , daily.dev community and connect with me on LinkedIn.
More Stories:
![](https://miro.medium.com/v2/resize:fill:388:388/1*XEMdvRO33SH2NpEI4hdZIQ.png)
![](https://miro.medium.com/v2/resize:fill:388:388/1*INH7xSwf1BjYi11vc1SeSA.png)
![](https://miro.medium.com/v2/resize:fill:388:388/1*lpLja1k_7cFagdzcn2tfEQ.png)