Day 12 of 100 Days of Cloud: Django on Serv00 - Hello World from the Cloud!
StackOverflowWarrior
Posted on July 29, 2024
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 ๐
- Navigate to serv00.com (remember to check for the actual URL)
- Click "Sign Up" and fill in your details
- Choose the free plan - perfect for our Hello World app!
- Confirm your email and you're in!
Step 2: Get Your Free Domain ๐
- In your Servo dashboard, look for "Free Domains"
- Choose a domain name (e.g., yourusername.serv00.com)
- 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 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
You're now in a fresh Python environment, perfect for our project!
Step 6: Install Django ๐
pip install django
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
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!")
Step 9: Configure URLs ๐
Edit helloworld/urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('', views.hello_world, name='hello_world'),
]
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
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()
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
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
Posted on July 29, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.