I already have a Django web application working, and I wanted to make it visible through Internet. I would even consider using Django alone, since it is only a prototype I want to show to someone, and security is not a priority for me right now. But since this looks impossible to achieve (or at least I haven't been able to do it), I'm moving to Apache.
The problem is that there are many tutorials, and each one do different things.
Until now I have: - Installed apache (and works) - Installed mod_wsgi (and module is loaded into Apache) - Since my Django web app is in /home/myuser/www/myapp/ (or at least that's where I'm storing the manage.py file, the rest of the application is in /home/myuser/www/myapp/myapp/), I tried to make apache point there. So I created (home/myuser/www/myapp/apache.conf/web.wsgi with the following content:
import os, sys
sys.path.append('/home/myuser/www/myapp/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
BTW I also have the wsgi Django automatically generates when creating a new project in /home/myuser/www/myapp/myapp/wsgi.py. Maybe I should use this one, but none of the tutorials I have found until now do mention this file. Any way, its content is:
import os
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "myapp.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from myapp.wsgi import MyAppApplication
# application = MyAppApplication(application)
Finally, I created the file /etc/apache2/sites-available/myapp, using the default one as a template, and looks like this:
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/myuser/www/myapp/
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        AddHandler mod_python .py
        PythonHandler mod_python.publisher | .py
        PythonDebug On
    </Directory>
    <Directory /home/myuser/www/myapp/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /home/myuser/www/myapp/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog /home/myuser/www/myapp/access.log combined
</VirtualHost>
Despite my efforts described, when I navigate to localhost I just see the default apache web, saying 'It works!'.
Any help please? What am I missing?