👥 VirtualHost config

Sun 17 Apr, 2022




In, for example:

/etc/apache2/sites-available/example.jcaston.uk

***

<VirtualHost *:80>
    ServerName example.jcaston.uk
    Redirect / https://example.jcaston.uk/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.jcaston.uk
    ServerAdmin admin@whatever.com

    ErrorLog /home/jamie/example.jcaston.uk/logs/error.log
    CustomLog /home/jamie/example.jcaston.uk/logs/access.log combined

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

    alias /static /home/jamie/example.jcaston.uk/static

    <Directory /home/jamie/example.jcaston.uk/static>
        Require all granted
    </Directory>

    <Directory /home/jamie/example.jcaston.uk/projectname/>
        <Files wsgi.py>
            Require all granted
    </Files>
    </Directory>

    WSGIDaemonProcess uniqueDaemonName python-path=/home/jamie/example.jcaston.uk python-home=/home/jamie/example.jcaston.uk/nameOfVirtualEnvironment
    WSGIProcessGroup uniqueDaemonName
    WSGIScriptAlias / /home/jamie/example.jcaston.uk/wsgi.py
</VirtualHost>

Once you've made changes make sure to:
sudo apachectl configtest

Hopefully we get the:
Syntax OK

At which point we can:
sudo systemctl reload apache2

blog.jcaston.uk // 2025