Awesome — let’s get Apache2 installed and set up with HTTPS (Let’s Encrypt) support.
✅ Step 1: Install Apache + HTTPS tools
apt update
apt install apache2 certbot python3-certbot-apache -y
✅ Step 2: Adjust firewall (if active)
ufw allow 'Apache Full'
ufw reload
Otherwise, you’re fine — Hetzner usually allows ports 80/443 by default.
✅ Step 3: Enable Apache & make sure it’s running
systemctl enable apache2
systemctl start apache2
systemctl status apache2
✅ Step 4: Set up HTTPS with Let’s Encrypt
✅ Wat je wél nodig hebt:
Je eigen certificaatbestanden, meestal:
Een certificaatbestand (yourdomain.crt of cert.pem)
En private key (yourdomain.key)
Soms een CA-bundle of intermediate chain (ca_bundle.crt of chain.pem)
Een aangepaste Apache Virtual Host-configuratie.
a2enmod ssl
a2ensite default-ssl
systemctl reload apache2
<IfModule mod_ssl.c>
<VirtualHost 148.251.89.72:443>
ServerName www.vindazo.nl
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/vindazo_nl_error.log
CustomLog ${APACHE_LOG_DIR}/vindazo_nl_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/vindazo_nl/www_vindazo_nl.crt
SSLCertificateKeyFile /etc/ssl/vindazo_nl/www.vindazo.nl.key
SSLCertificateChainFile /etc/ssl/vindazo_nl/www_vindazo_nl.ca-bundle
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{SERVER_NAME} 148.251.89.72
RewriteRule /(.*) https://www.vindazo.nl/$1 [R=301,L]
LimitRequestBody 536870912
WSGIDaemonProcess www.vindazo.nl python-home=/home/admin/venv_vindazo python-path=/home/admin/deployment/nl_vindazo/vindazo processes=10 threads=100 maximum-requests=1000 display-name=%{GROUP}
WSGIProcessGroup www.vindazo.nl
WSGIScriptAlias / /home/admin/deployment/nl_vindazo/vindazo/jobfor/wsgi.py
apt install libapache2-mod-wsgi-py3 -y
a2enmod wsgi
systemctl restart apache2
chown -R www-data:www-data /var/www/
Require all granted
This will:
-
Install the right version of
mod_wsgi
for Python 3 -
Enable it in Apache
-
Allow directives like
WSGIDaemonProcess
,WSGIProcessGroup
, andWSGIScriptAlias
to work1️⃣ Is Apache listening on port 443?
ss -tulpen | grep apache2
netstat -tuln | grep 443
2️⃣ Is SSL module enabled?
a2enmod ssl
a2ensite default-ssl
systemctl reload apache23️⃣ Do you have a valid SSL config (with purchased cert)?
SSLCertificateFile /etc/ssl/vindazo/vindazo.crt
SSLCertificateKeyFile /etc/ssl/vindazo/vindazo.key
SSLCertificateChainFile /etc/ssl/vindazo/ca_bundle.crt
What we're going to do:
✅ 1. Check which Python version your project is running
✅ 2. Make sure you have a virtualenv with Python 3
(venv_vindazo) root@Vindazo /home/admin/deployment/nl_vindazo/vindazo #
✅ 3. Upgrade old code to Python 3 compatible
✅ 4. Prepare WSGI and Apache for Python 3
(venv_vindazo) root@Vindazo /home/admin/deployment/nl_vindazo/vindazo #
import os
import sys
sys.path.insert(0, '/home/admin/deployment/nl_vindazo/vindazo')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jobfor.settings.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Comments
Post a Comment