I have a simple, Django application which I would like to push to production on a Google Compute Engine (GCE) server. The GCE server is running Debian-Wheezy. I have installed Apache 2, Django 1.6.2 and mod-wsgi on the server and set up a firewall rule which opens port tcp:80.
I am attempting to follow the instructions at https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/. However, I have been unable to find the httpd.conf file to modify.
Questions:
- Where can I find this httpd.conf file to modify?
- Once found, do I just edit it as shown at the webpage and then any visits to the GCE instance's external IP address will be directed to my Django application?
Edit 1:
In my root I have the following folders:
bin boot build dev etc home initrd.img lib lib64 media mnt opt proc root run sbin selinux srv sys tmp usr var vmlinuz
Follwing advice from: http://commanigy.com/blog/2011/06/08/finding-apache-configuration-file-httpd-conf-location I have run the following:
$ ps -ef | grep apache
which returns
jason@instance-1:/$ ps -ef | grep apache
root 10492 1 0 13:33 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 10495 10492 0 13:33 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 10496 10492 0 13:33 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 10497 10492 0 13:33 ? 00:00:00 /usr/sbin/apache2 -k start
jason 11669 11529 0 16:54 pts/1 00:00:00 grep apache
and then
$ /usr/sbin/apache2 -V
which returns
Server version: Apache/2.2.22 (Debian)
Server built: Feb 1 2014 21:26:17
Server's Module Magic Number: 20---edited-just-in-case
Server loaded: APR 1.4.6, APR-Util 1.4.1
Compiled using: APR 1.4.6, APR-Util 1.4.1
Architecture: 64-bit
Server MPM: Worker
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/worker"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"
According to that website the file I'm actually looking for is apache2.conf not httpd.conf – though this contradicts the Django documentation…
Edit 2
To answer @ls97 question, at /usr/sbin/apache2 is a symbolic link which points to
apache2 -> ../lib/apache2/mpm-worker/apache2
If I navigate to this location and run $ ls -al
I get
total 496
drwxr-xr-x 2 root root 4096 Apr 18 13:27 .
drwxr-xr-x 7 root root 4096 Apr 18 13:27 ..
-rwxr-xr-x 1 root root 497808 Feb 1 21:27 apache2
And the apache2
item at this location is not a directory.
Best Answer
apache2.conf
is usually under/etc/apache2/
and is the apache main configuration file. It loadshttpd.conf
which is where you should place your configurations (and not in the main file).update:
So, in
/etc/apache2/apache2.conf
file, you certainly have lines like these 2 somewhere:The last one will include
/etc/apache2/httpd.conf
file which is probably an empty file (or almost) on a fresh install. If it doesn't exist, you can create a new one and add:You can add your global configurations and virtualhosts configurations there as stated in the django tutorial. As I know the virtualhost part is not in django tutorial (because it is not django related but apache), here is a starting example from a working django site:
You need to install and enable wsgi module on apache of course. Usually it is already there and you only need to enable it with:
sudo a2enmod wsgi
. Not sure about that but I suppose it's enabled for you by GCE based on your configuration for python/django.Also beware if you are using apache before 2.4, there is a note in django tutorial to change
Require all granted
withAllow from all
and select permission order.I think this is the simplest way to do it. Another method I prefer for multiple virtualhosts, is to use a directory called
sites-available
to store 1 file per vhost and enable them selectively linking tosites-enabled
. You can find examples of how to do it in apache documentation but working inhttpd.conf
is fine too for a small number of sites.