Reputation: 379
I want to run my Django app created in virtualenv on ubuntu with python3. Folder structure in virtualenv folder:
-bin
-include
-lib
-myapp
-share
pip-selfcheck.json
The myapp folder contains my application with apache folder configured as specified in this tutorial: https://www.sitepoint.com/deploying-a-django-app-with-mod_wsgi-on-ubuntu-14-04/ I have all apps installed I need in my virtualenv, after 'sudo service apache2 restart' I see only Apache2 Ubuntu Default Page. File /etc/apache2/sites-enabled/000-default.conf is like in the tutorial:
<VirtualHost *:80>
WSGIScriptAlias / /home/myuser/mysite/apache/wsgi.py
<Directory "/home/myuser/mysite/apache/">
Require all granted
</Directory>
</VirtualHost>
Of course with correct paths pointing to my project location in 'venv' folder. No idea where to move on, what to check, thanks for suggestions.
EDIT: I realy dont get this, I edited the mentioned file, had a try, nothing happened so I edited it back and after restart it it worked.
Upvotes: 0
Views: 735
Reputation: 21
I have Ubuntu 20.04 and Apache2. I followed the mod_wsgi installation instructions linked to here but forgot to enable the module in /etc/apache2/apache2.conf
(or to include a file from apache2.conf that does so). I added that and then the WSGIScriptAlias / /home/myuser/mysite/apache/wsgi.py
directive in my 000-default.conf did not cause an error when I restarted the server with systemctl restart apache2
Upvotes: 0
Reputation: 379
So after editing the file, restarting apache, editing the file back it works (/etc/apache2/sites-enabled/000-default.conf). Really dont get it, several restarts yesterday did not help...
Upvotes: 1
Reputation: 58523
The official Django documentation on using mod_wsgi can be found at:
It may be better to consult that for how to set things up specifically for Django, you are missing various required configuration elements.
As to why you are still getting the default page, it could be because you added that configuration as an extra thing to the end of the default sites file, rather than inserting the contents of the VirtualHost
you have into the existing VirtualHost
in that file. If you added it after, it will be ignored as it will still use the existing VirtualHost
as it comes first and you haven't set up correctly named based hosting.
Also be aware that where other people say you should use something else, every solution will have a learning curve if this is all new. No solution is simple if you want to integrate into your existing host system. So jumping around looking at different solutions can be a great waste of time. Select one which you think you like and stick with it. The idea that one is superior to others is in general nonsense as their performance is similar.
I would actually suggest you skip even trying to integrate it into your host system to begin with if you are just playing. Use a WSGI server that you can run from the command line, even if it is just the bundled development server with Django. Options which are simple to run from the command line are:
Upvotes: 1