This guide will help you deploy GhostSec on PythonAnywhere's free tier.
- Go to https://www.pythonanywhere.com/registration/register/beginner/
- Sign up for a free "Beginner" account
- Remember your username - your site will be yourusername.pythonanywhere.com
- After logging in, go to the Dashboard
- Click on "Web" tab
- Click "Add a new web app"
- Choose:
- Python 3.10
- Manual configuration (not Django)
- Go to "Consoles" tab
- Click "Bash console"
- Create and activate virtual environment:
mkvirtualenv --python=/usr/bin/python3.10 ghostsec
workon ghostsec
- Install requirements:
pip install django==4.2.7 gunicorn psycopg2-binary redis django-redis whitenoise
- In the Bash console:
cd ~
git clone https://github.com/YourUsername/GhostSec.git
cd GhostSec
- Create production settings:
mkdir -p ghostsec/settings
touch ghostsec/settings/__init__.py
- Edit production.py:
from .base import *
DEBUG = False
ALLOWED_HOSTS = ['yourusername.pythonanywhere.com']
# Static files
STATIC_ROOT = '/home/yourusername/GhostSec/static'
STATIC_URL = '/static/'
# Media files
MEDIA_ROOT = '/home/yourusername/GhostSec/media'
MEDIA_URL = '/media/'
# Security
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_BROWSER_XSS_FILTER = True
# Use WhiteNoise for static files
MIDDLEWARE.insert(1, 'whitenoise.middleware.WhiteNoiseMiddleware')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
# Database - using SQLite for free tier
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Cache - using local memory for free tier
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
}
}
- Go to Web tab
- Click on your web app
- Scroll to "Code" section
- Click on WSGI configuration file
- Replace contents with:
import os
import sys
path = '/home/yourusername/GhostSec'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'ghostsec.settings.production'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
-
In Web tab, add static files mapping:
- URL: /static/
- Directory: /home/yourusername/GhostSec/static
-
Collect static files:
python manage.py collectstatic
- Run migrations:
python manage.py migrate
- Create superuser:
python manage.py createsuperuser
- In Web tab, set virtual environment:
- /home/yourusername/.virtualenvs/ghostsec
- Click the green "Reload" button in Web tab
- Go to https://yourusername.pythonanywhere.com
- Log in with your superuser credentials
- Share your site URL: https://yourusername.pythonanywhere.com
- Create accounts for them through admin interface:
- Go to /admin
- Log in with superuser account
- Add new users
- Error log: Click "Error log" in Web tab
- Server log: Click "Server log" in Web tab
- Access log: Click "Access log" in Web tab
cd ~/GhostSec
git pull
python manage.py migrate
python manage.py collectstatic
Then click "Reload" in Web tab
- 512MB storage
- Limited CPU usage
- SQLite database
- One web app
- yourusername.pythonanywhere.com domain
- Check error logs in Web tab
- Verify WSGI configuration
- Check allowed hosts in settings
- Run collectstatic again
- Check static files mapping
- Verify STATIC_ROOT setting
- Check if migrations are applied
- Verify database file permissions
- Check available storage space
If you encounter issues:
- Check the error logs
- Review this guide's troubleshooting section
- Visit PythonAnywhere Forums
- Create an issue on GitHub