DEV Community

StackOverflowWarrior
StackOverflowWarrior

Posted on

Day 12 of 100 Days of Cloud: Django on Serv00 - Hello World from the Cloud!

Welcome to Day 12 of our exciting 100 Days of Cloud journey! Today, we're going to create a simple Django "Hello World" application and host it on Serv00. No Git required - we're starting from scratch! Let's dive in and make the cloud echo our greeting! 🌟

Step 1: Create Your Serv00 Account πŸŽ‰

  1. Navigate to serv00.com (remember to check for the actual URL)
  2. Click "Sign Up" and fill in your details
  3. Choose the free plan - perfect for our Hello World app!
  4. Confirm your email and you're in!

Step 2: Get Your Free Domain 🌐

  1. In your Servo dashboard, look for "Free Domains"
  2. Choose a domain name (e.g., yourusername.serv00.com)
  3. Click to activate it - this is where our app will live!

Step 3: Enable Run your own applications πŸ”§
In your Servo account settings, under additional services,Enable Run your own applications. This allows you to use custom software on your account.

Step 4: SSH Into Your Server πŸ–₯️
Open your terminal and type:

ssh yourusername@sx.serv00.com
Enter fullscreen mode Exit fullscreen mode

Enter your password when prompted. Welcome to your cloud server!

Step 5: Create a Virtual Environment 🌿

mkdir /usr/home/LOGIN/.virtualenvs
cd /usr/home/LOGIN/.virtualenvs
virtualenv django_env -p python3.10
source django_env/bin/activate
Enter fullscreen mode Exit fullscreen mode

You're now in a fresh Python environment, perfect for our project!

Step 6: Install Django 🐍

pip install django
Enter fullscreen mode Exit fullscreen mode

This installs the latest version of Django in your virtual environment.

Step 7: Create Your Django Project πŸš€

cd /usr/home/LOGIN/domains/YOURDOMAIN
django-admin startproject helloworld
mv helloworld public_python
cd public_python
Enter fullscreen mode Exit fullscreen mode

This creates a new Django project and moves it to the correct directory.

Step 8: Create a Simple View πŸ‘‹
Edit helloworld/views.py:

from django.http import HttpResponse

def hello_world(request):
    return HttpResponse("Hello, Cloud World!")
Enter fullscreen mode Exit fullscreen mode

Step 9: Configure URLs πŸ”—
Edit helloworld/urls.py:

from django.urls import path
from . import views

urlpatterns = [
    path('', views.hello_world, name='hello_world'),
]
Enter fullscreen mode Exit fullscreen mode

Step 10: Adjust Settings βš™οΈ
Edit helloworld/settings.py:

  • Set DEBUG = False
  • Add your Servo domain to ALLOWED_HOSTS
  • Configure STATIC_ROOT = '/usr/home/LOGIN/domains/YOURDOMAIN/public_python/public/'

Step 11: Collect Static Files 🎨

python manage.py collectstatic
Enter fullscreen mode Exit fullscreen mode

Step 12: Create passenger_wsgi.py πŸš—
In your public_python directory, create passenger_wsgi.py:

import os
import sys

sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = 'helloworld.settings'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Enter fullscreen mode Exit fullscreen mode

Step 13: Configure WWW Settings in Servo Panel πŸŽ›οΈ

  • Set Python version to 3.10
  • Set executable to /usr/home/LOGIN/.virtualenvs/django_env/bin/python
  • Set application directory to /usr/home/LOGIN/domains/YOURDOMAIN/public_python

Step 14: Restart Your Application πŸ”„

devil www YOURDOMAIN restart
Enter fullscreen mode Exit fullscreen mode

Step 15: Visit Your Site 🌍
Open your browser and go to your Servo domain. You should see "Hello, Cloud World!"

Congratulations! You've just deployed your first Django app to the cloud! πŸŽ‰πŸŽŠ

Remember, cloud explorers, every great journey begins with a single step - or in our case, a single "Hello World"! This simple app is your launchpad to bigger cloud adventures.

Before we sign off, here's a cloud joke to keep you floating:
Why don't clouds ever wear shoes?
Because they prefer to go barefoot! β˜οΈπŸ‘£

Stay tuned for Day 13, where we'll add more features to our cloud-based greeting. Until then, keep your spirits high and your latency low! πŸš€β˜οΈ

100DaysOfCloud #Django #Serv00 #WebHosting #CloudComputing

Top comments (0)