Host Django application in the Lightsail's built in Apache server

1.4k views Asked by At

I want to have a production ready Django app with Lighsail and for that I'm following two tutorials to achieve this

From the Bitnami article can see that the AWS documentation follows its Approach B: Self-Contained Bitnami Installations.

According to:

  • AWS's documentation, my blocker appears in 5. Host the application using Apache, step g.
  • Bitnami's documentation, where it says

On Linux, you can run the application with mod_wsgi in daemon mode. Add the following code in /opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-app.conf:

The blocker relates to the code I'm being asked to add, in particular the final part that has

Alias /tutorial/static "/opt/bitnami/apps/django/lib/python3.7/site-packages/Django-2.2.9-py3.7.egg/django/contrib/admin/static"
WSGIScriptAlias /tutorial '/opt/bitnami/apps/django/django_projects/tutorial/tutorial/wsgi.py'

More specifically, /home/bitnami/apps/django/. In /home/bitnami/ can only see the following folders . bitnami_application_password . bitnami_credentials . htdocs . stack

and from them the one that most likely resembles /opt/bitnami/apps/ is /home/bitnami/stack/. Thing is, inside of that particular folder, there's no django folder - at least as far as I can tell (already checked inside some of its folders, like the python one).

The workaround for me at this particular stage is to move to a different approach, Approach A: Bitnami Installations Using System Packages (which I've done and managed to make it work as wrote in this blog post), but I'd like to get it to work using Approach B and hence this question.

1

There are 1 answers

0
Tiago Martins Peres On BEST ANSWER

The problem here is in the mentioning of the paths for both the project and Django.

Actual Bitnami folder

In my case, projects are under /home/bitnami/projects/ where I created a Django project named tutorial.

Also, if I run the command

python -c "
import sys
sys.path = sys.path[1:]
import django
print(django.__path__)"

it'll print me the location where Django is installed

['/opt/bitnami/python/lib/python3.8/site-packages/django']

Bitnami opt folder not as expected

So, the httpd-app.conf should have instead at the end

Alias /tutorial/static "/opt/bitnami/python/lib/python3.8/site-packages/django/contrib/admin/static"
WSGIScriptAlias /tutorial '/home/bitnami/projects/tutorial/tutorial/wsgi.py'