Configuring Mezzanine for Apache server & mod_wsgi in AWS
By Güngör Budak
- One minute read - 179 wordsInstall [Mezzanine]({% post_url 2015-05-01-how-to-install-mezzanine-on-ubuntulinux-mint %}), [Apache server]({% post_url 2015-05-08-getting-started-with-your-aws-instance-and %}) and mod_wsgi:
sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
Set up a MySQL database for your Mezzanine project
Read [my post on how to set up a MySQL database for a Mezzanine project]({% post_url 2015-05-09-how-to-set-up-a-mysql-database-for-a-mezzanine %})
Collect static files:
python manage.py collectstatic
Configure your Apache server configuration for the project like following:
WSGIPythonPath /home/ubuntu/www/mezzanine-project
<VirtualHost *:80>
#ServerName example.com
ServerAdmin admin@example.com
DocumentRoot /home/ubuntu/www/mezzanine-project
WSGIScriptAlias / /home/ubuntu/www/mezzanine-project/wsgi.py
Alias /static /home/ubuntu/www/mezzanine-project/static/
<Directory /home/ubuntu/www/mezzanine-project>
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Note: Replace mezzanine-project
with the name of your project
Configure wsgi.py
(I don’t know why but it needs this fix - complete script):
1from __future__ import unicode_literals
2import os
3import sys
4
5PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
6sys.path.append(os.path.join(PROJECT_ROOT, ".."))
7settings_module = "%s.settings" % PROJECT_ROOT.split(os.sep)[-1]
8os.environ["DJANGO_SETTINGS_MODULE"] = settings_module
9
10from django.core.wsgi import get_wsgi_application
11application = get_wsgi_application()
Enable the site and restart the server:
sudo a2ensite mezzanine-project.conf
sudo service apache2 restart
Now, when you navigate to your AWS public DNS, your Mezzanine project should be running.
Source: Vimmaniac