djangoapacheubuntuwsgimezzanine

Can't Deploy Mezzanine CMS using Apache/Ubuntu


I'm trying to become better with deploying a website from scratch so I setup a new Nanode from Linode using the latest Ubuntu (19.04 I think).

I followed the instructions to install Mezzanine CMS (Django Based) and it all went fine, I was able to run the dev server to test the website fine on port 8000.

I did install UFW and right now only activity on port 80 is not rejected. Also I have mysql database running with Mezzanine not Djangos default SQLlite.

I installed Apache and WSGI. At first Apache would not restart due to some configuration issue which I think I've since worked out.

I have a domain alexmerced which is on godaddy, but I have a DNS "a" records which is pointing to my linodes IP address "mezz.alexmerced.com"

Mezzanine is still a fresh install so I haven't really changed anything outside of the WSGI and settings.py.

I currently get a forbidden error when I type the URL or IP address, the permissions of the application directory is 755.

below are my configuration file settings to see if I made any mistakes.

django_project.conf (the only conf file enabled in the /sites-available/ directory

<VirtualHost *:80>
    ServerName mezz.alexmerced.com
    ServerAdmin mezzanine@localhost
    DocumentRoot /mymezz
    WSGIScriptAlias / /mymezz/mymezz/wsgi.py
    Alias /static /mymezz/static/

    <Directory /mymezz/>
    <Files wsgi.py>
        Require all granted
    </Files>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

here is the wsgi.py file

"""
WSGI config for mymezz project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name

os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                  "%s.settings" % real_project_name("mymezz"))

application = get_wsgi_application()

other stuff I read on asked me to add the following to my settings.py

PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(PROJECT_ROOT, ".."))
settings_module = "%s.settings" % PROJECT_ROOT.split(os.sep)[-1]
os.environ["DJANGO_SETTINGS_MODULE"] = settings_module

and

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Solution

  • I never did figure this out with Apache, but I did successfully deploy this blog using Nginx and Uwsgi, just be careful regarding the path your virtual environment once completed I realized that was the problem I was having apache.