0

I am able to set up my domain for https without problems with the following example.com.conf file:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /www/example.com

    ErrorLog /var/log/example.com/error.log

    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined

    RewriteEngine on

</VirtualHost>

Then I run certbot --apache, choose my domain, install the certificate and then choose option 2: Secure - Make all requests redirect to secure HTTPS access. The file example.com-le-ssl.conf is created like this:

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /www/example.com

        ErrorLog /var/log/example.com/error.log

        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined

        RewriteEngine on

        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
    </VirtualHost>
</IfModule>

and visiting example.com redirects to https://example.com and going directly to https://example.com also works fine.

Now I would like to change the apache config to work with django

I have tried using the example.com.conf file at the bottom and then run the certbot --apache command, but it gives the error

Name duplicates previous WSGI daemon definition.

I also tried changing the file after having it working as shown above, but with no luck. Any idea how to do this properly?

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    WSGIPassAuthorization On


    WSGIDaemonProcess myapp  python-home=/opt/MyProject-Master python-path=/opt/MyProject-Master/MyProject processes=2 threads=5

    WSGIProcessGroup myapp
    WSGIScriptAlias / /path/MyProject-Master/MyProject/MyProject/wsgi.py process-group=myapp
    <Directory /path/MyProject-Master/MyProject/MyProject>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    ErrorLog /var/log/example.coms/error.log

    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined

</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.