I scanned tons of links on this topic, devoted to the deployment of Django and Apache on Ubuntu server. Finally, I found this link Django Deployement Installation to Ubuntu 12.04 Server which brought me further than any other guide. So, now, I'm at this point - I installed all software and dependencies, enabled mod_WSGI, installed Python environment and Django, started a new project etc. I called my domain name 'dynamics'. So, my dynamics file in /etc/apache2/sites-available folder now looks like this:
<VirtualHost *:80>
ServerAdmin root@dynamics
ServerName dynamics
Alias /site_media/ /srv/my_project/app/webapp/site_media/
Alias /static/ /srv/my_project/venv/lib/python2.7/site-packages/django/contrib/admin /static/
Alias /robots.txt /srv/my_project/app/webapp/site_media/robots.txt
Alias /favicon.ico /srv/my_project/app/webapp/site_media/favicon.ico
CustomLog "|/usr/sbin/rotatelogs /srv/my_project/logs/access.log.%Y%m%d-%H%M%S 5M" combined
ErrorLog "|/usr/sbin/rotatelogs /srv/my_project/logs/error.log.%Y%m%d-%H%M%S 5M"
LogLevel warn
WSGIDaemonProcess dynamics user=itsme group=itsme processes=1 threads=15 maximum- requests=10000 python-path=/srv/my_project/venv/lib/python2.7/site-packages python- eggs=/srv/my_project/run/eggs
WSGIProcessGroup dynamics
WSGIScriptAlias / /srv/my_project/app/conf/apache/django.wsgi
<Directory /srv/my_project/app/webapp/site_media>
Order deny,allow
Allow from all
Options -Indexes FollowSymLinks
</Directory>
<Directory /srv/my_project/app/conf/apache>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
But, when I start apache and go to localhostI see Not found error, if I instead try to go to http://dynamics/ I'm redirected to google search page. I think I need to make some extra configurations, but I do not know which ones. Probably, I need to specify ServerRoot in apache.conf (but again with all this django folders I do not know where I should exactly point to).
EDIT Now, it is even worse. I tried to reinstall apache, but when I go to localhost, browser wants to load a page like a file. So, what I did step by step:
1. sudo apt-get remove apache2 # remove to install from scratch
2. sudo apt-get update
3. sudo apt-get install apache2
4. sudo a2dissite default # disable the default site
5. create dynamics file in /etc/apache2/sites-available
6. dynamics file contains these lines:
<VirtualHost *:80>
ServerAdmin root@dynamics
ServerName dynamics
DocumentRoot /home/username/Sites/dynamics
<Directory /home/username/Sites/dynamics/>
Options Indexes FollowSymLinks MultiViews
AllowOverride Node
Order allow,deny
allow from all
</Directory>
</VirtualHost>
7. /etc/apache2/apache2.conf contains `ServerName dynamics`.
If I also specify SeverRoot to /home/username/Sites/dynamics I get hundreds of errors, when I restart apache, so I do not specify it.
Problems:
1. If I go to `http://dynamics`, I'm redirected to google search page
2. If I go to localhost, the browser wants to load a page like a file
So, after reinstallation I even one step back. I can't even make a virtual host. During this process I encountered one thing - if you do sudo apt-get remove or sudo apt-get purge, in spite of what they say, I still see apache config files untouched - just as they were before uninstallation. So, I now have one extra question:
1. How to uninstall completely apache. All guides and tips that I followed left apache config files just as they were.
EDIT
Well, I reinstalled apache from the very start, added a virtual host dynamics (firstly, without any link with django), then I followed Daniel Roseman advice - corrected hosts file a little bit. And not, at least, this part works. I can add index.html file to dynamics folder and if I go to http://dynamics/ I see this page rendered. BUT, all my attempts to build a django project and run in at the same URL http://dynamics ended in failure. Every time I get this error 'Not found'. Tons of guides, hundreds of blogs and oceans of manuals seem to be completely useless to make (I think) the simplest possible task - just to run a django project on Apache.
EDIT
I will start a bounty question. Now, I just want to formalize everything beforehand. The question is How to deploy Django and Apache on Ubuntu? Requirements:
Strongly required:
1. Ubuntu 12.04
2. Python 3.3.4
3. Apache 2.2.22
4. mod_wsgi
Not so strongly: 5. If someone will make a running test-case, that wiil be cool. So, my final aim is to make a tiny web-project where I could use f2py to call fortran subroutines. If that connection is possible to do in this environment, I will be totally over the moon. And lets say I want to have a concrete virtualhost called dynamics. So, I want to store all project's files in this directory /home/victor/dynamics/. I need a step by step instruction, not just shreds of tips. And hope this instruction, if someone will manage to make it, will be incredibly popular among django newbeis like me.
sudo apt-get purge apache2. It will remove also any configuration files belonging to the packages.removeandpurgeleave apache2.conf untouched