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

tutorialhelldev

StackOverflowWarrior

Posted on July 29, 2024

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

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
tutorialhelldev
StackOverflowWarrior

Posted on July 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About