Deploying Laravel (or Django) Apps on Sternhost: From Zero to Live
Getting your modern web application from code to production doesn’t have to be complicated. In this tutorial, we’ll cover two popular frameworks—Laravel (PHP) and Django (Python)—and show you how to deploy them on Sternhost from an empty server to a live, secure site.
Why Choose Sternhost for Framework Apps?
- Optimized Environments for PHP and Python
- SSH & Composer/Pip preconfigured on VPS plans
- Easy Virtual Host Setup via cPanel
- Free SSL, automated backups, and 24/7 expert support
Common Prerequisites
- Sternhost VPS or Dedicated Plan (required SSH access).
- Domain Pointed to your Sternhost nameservers.
- SSH Key installed in your Sternhost control panel for secure login.
- Basic CLI Knowledge (SSH, composer, pip).
Part 1: Deploying a Laravel App
1. Connect via SSH & Prepare Server
ssh youruser@your.server.ip
cd ~
- Update packages
sudo apt update && sudo apt upgrade -y
- Install PHP dependencies (if not already)—Laravel requires PHP 8.x, extensions, Composer:
sudo apt install php php-mbstring php-xml php-zip php-mysql php-pdo unzip -y curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
2. Upload or Clone Your Laravel Project
- Git clone:
git clone https://github.com/yourname/your-laravel-app.git public_html
- Or upload your project ZIP via cPanel File Manager into
~/public_html
, then extract.
3. Install Dependencies & Environment
cd public_html
composer install --optimize-autoloader --no-dev
cp .env.example .env
php artisan key:generate
Edit .env
to configure:
APP_URL=https://yourdomain.com
DB_HOST=localhost
DB_DATABASE=your_db
DB_USERNAME=your_user
DB_PASSWORD=your_pass
4. Set Up Database
- In cPanel → MySQL® Databases, create a database and user.
- Grant all privileges, then run:
php artisan migrate --force
5. Configure Virtual Host & SSL
- In cPanel → Domains → Addon Domains (or Subdomains), point
yourdomain.com
topublic_html/public
. - Enable SSL via SSL/TLS → Let’s Encrypt.
- In
.htaccess
(insidepublic_html/public
), ensure Laravel’s rewrite rules:<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule>
6. Optimize & Go Live
php artisan config:cache
php artisan route:cache
php artisan view:cache
Visit **https://yourdomain.com**—your Laravel app is live!
Part 2: Deploying a Django App
1. Connect via SSH & Prepare Server
ssh youruser@your.server.ip
Install Python 3, pip, virtualenv:
sudo apt update && sudo apt install python3 python3-venv python3-pip -y
2. Upload or Clone Your Django Project
cd ~
git clone https://github.com/yourname/your-django-app.git
mv your-django-app public_html
3. Create Virtual Environment & Install Requirements
cd public_html
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
4. Configure Django Settings
In settings.py
:
ALLOWED_HOSTS = ['yourdomain.com']
DEBUG = False
STATIC_ROOT = BASE_DIR / 'staticfiles'
Collect static files:
python manage.py collectstatic --noinput
5. Set Up Database
If using MySQL/PostgreSQL:
- Create DB & user in cPanel → MySQL® Databases or PostgreSQL® Databases.
- Update
DATABASES
insettings.py
. - Run migrations:
python manage.py migrate
6. Configure uWSGI and Apache (via cPanel)
- In cPanel → Setup Python App:
- Choose Python 3.x
- Set “Application root” to
public_html
- “Application startup file” to
passenger_wsgi.py
(create this file next)
- Create
passenger_wsgi.py
inpublic_html
:import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'yourproject.settings') application = get_wsgi_application()
- Restart the Python app in cPanel.
7. Enable SSL & Test
- Enable Let’s Encrypt SSL in SSL/TLS.
- Visit https://yourdomain.com to confirm.
Troubleshooting & Tips
- Permissions: Ensure
storage
(Laravel) orstaticfiles
(Django) directories are writable (chmod -R 755
). - Logs: Check
storage/logs/laravel.log
or Django’serror_log
via cPanel’s Metrics → Errors. - Support: Sternhost’s 24/7 team can assist with server-level issues—open a ticket via the Support Portal.
Conclusion
Deploying Laravel or Django on Sternhost is fast and reliable when you follow these steps. From SSH setup to SSL configuration, our platform gives you the tools to launch robust, production-ready applications. Ready to deploy? Log in to your Sternhost cPanel and go live today!