-
Notifications
You must be signed in to change notification settings - Fork 8
New Server
This section is intended for those who have a brand new server or one without any django or python web server services
The following instructions are for Ubuntu 11, but the steps should be translatable to your OS of choice. It also describes a possible web server setup and not the only way to do this as your needs may differ.
Required
- Apache
- nginx
- Python 2.6+
- MySQL
- PIL
Search
- Java 1.6+
- Django Haystack
##Project Dir
First make a project dir, i'm going to use /var/www/dev
mkdir /var/www/dev
And a separate static dir
mkdir /var/www/static
##Apache & Nginx The idea here is that nginx will sit in front of everything. Nginx is a lightweight and fast webserver, though for this tutorial, we'll just be using it to serve static files like images and javascript. So Nginx will redirect traffix to apache when it's a django request and just server the static files when not. I believe this is a typical setup. So Apache will listen on port :8080 and Nginx on port :80.
Ubuntu comes packaged with apache 2 already so nothing more is required to be installed. Though we do need to configure it. So we'll need to grab nginx:
sudo aptitude install nginx
###Configure First install mod_wsgi For apache we just need to set up a virtual host on port :8080 so edit the apache.conf file:
<VirtualHost *:8080>
DocumentRoot /var/www/dev
WSGIScriptAlias / /var/www/dev/wsgi.py
WSGIPythonPath /var/www/dev
<Directory /var/www/dev>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</VirtualHost>
Nginx will have a more fleshed out conf file. So edit /etc/nginx/nginx.conf. You'll only need to edit the server section of the default conf:
...
server {
listen 80;
server_name dev;
access_log logs/www.dev.log main;
# serve django admin files
# This location may differ based on your setup
location ~ ^/(media)/ {
root /usr/lib/python2.7/site-packages/django/contrib/admin;
expires 30d;
}
# serve static files
location ~ ^/(static)/ {
root /var/www;
expires 30d;
}
# pass requests for dynamic content
location / {
proxy_pass http://127.0.0.1:8080;
}
}
...
##MySQL I'm using MySQL, but you could use postgres if that's what you are already using. Ubuntu comes with MySQL 5, so no need to install anything further. We just need the python bindings: apt-get install python-mysqldb
##Django Download it here, then: tar xzvf Django-1.4.tar.gz cd Django-1.4 sudo python setup.py install
##PIL Finally we need Python Imaging Library. We'll use Pillow as its just an easier install that yeilds the same lib: sudo pip uninstall PIL sudo pip install pillow
You should be all set, just restart the web servers and follow the install instructions for frog.
Restart apache and nginx: sudo /etc/init.d/apache2 restart sudo /etc/init.d/nginx start