summaryrefslogtreecommitdiff
path: root/tech/set up geodjango on debian 7 digital ocean.txt
diff options
context:
space:
mode:
Diffstat (limited to 'tech/set up geodjango on debian 7 digital ocean.txt')
-rw-r--r--tech/set up geodjango on debian 7 digital ocean.txt98
1 files changed, 98 insertions, 0 deletions
diff --git a/tech/set up geodjango on debian 7 digital ocean.txt b/tech/set up geodjango on debian 7 digital ocean.txt
new file mode 100644
index 0000000..475c6eb
--- /dev/null
+++ b/tech/set up geodjango on debian 7 digital ocean.txt
@@ -0,0 +1,98 @@
+the first thing we need is python 3.4+ which I install by hand:
+
+prereqs:
+sudo apt-get install build-essential libncursesw5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev libreadline6-dev
+
+wget https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz
+tar -xvzf Python-3.4.1.tgz
+cd Python-3.4.1
+./configure --prefix=/opt/python3
+make
+sudo make altinstall
+
+Then we need postgres and the geospatial libs:
+
+apt-get install postgresql postgresql-contrib binutils libproj-dev gdal-bin
+
+
+
+postgis 2 i also do from source:
+
+wget http://download.osgeo.org/postgis/source/postgis-2.1.3.tar.gz
+tar -xvzf postgis-2.1.3.tar.gz
+cd postgis-2.1.3
+
+preqs:
+
+apt-get install libpq-dev postgresql-server-dev-all libxml2 libgeos-dev libxml2-dev gdal-bin libgdal-dev
+
+./configure
+make
+sudo make install
+
+Then you just need to create a db user and database
+
+sudo su - postgres
+createuser -P -s -e luxagraf
+
+The with regular user:
+createdb luxagraf -U luxagraf -W -hlocalhost
+psql -U luxagraf -W -hlocalhost -d luxagraf
+and when you're in postgres:
+CREATE EXTENSION postgis;
+
+Then just load the data:
+psql -U luxagraf -W -hlocalhost -d luxagraf -f fullbak.sql (or whatever your backupfile is)
+
+
+The last thing is a virtualenv for our project using python3.4
+
+#make sure you use the right pip (included with python 3.4+)
+sudo /opt/python3/bin/pip3.4 install virtualenv
+then cd to proj dir and do:
+/opt/python3/bin/virtualenv --distribute --python=/opt/python3/bin/python3-4 venv
+then activate and install what you need
+
+---
+Once that's set up we need to connect gunicorn to nginx via supervisor.
+
+ sudo apt-get install supervisor
+
+That will install and start supervisor. Let's add an init script so that supervisord starts up should the server need to reboot. so create the file
+
+ /etc/init.d/supervisord
+
+And grab the appropriate [init script from the supervisor project](https://github.com/Supervisor/initscripts). I use the Debian script from that link. Paste that script into `/etc/init.d/supervisord` and save. Then make it executable:
+
+ sudo chmod +x /etc/init.d/supervisord
+
+Now, make sure supervisor isn't running:
+
+ supervisorctl shutdown
+
+And add supervisor to
+
+With Supervisor installed you can start and watch apps by creating configuration files in the `/etc/supervisor/conf.d` directory. You might do something like this, in, for example, `/etc/supervisor/conf.d/helloworld.conf`:
+
+ [program:helloworld]
+ command = /home/<username>/apps/mydjangoapp/venv/bin/gunicorn -c /home/<username>/apps/mydjangoapp/config/gunicorn_config.py config.wsgi
+ directory = /home/<username>/apps/mydjangoapp/
+ user = <non-privledged-user>
+ autostart = true
+ autorestart = true
+ stdout_logfile = /var/log/supervisor/helloworld.log
+ stderr_logfile = /var/log/supervisor/helloworld_err.log
+
+You'll need to fill in the correct paths based on your server setup, replacing <username> with your username and `mydjangoapp/etc...` with the actual path to the gunicorn app. This also assumes your gunicorn config file lives in `mydjangoapp/config/`. We'll get to that file in a minute.
+
+First, let's tell supervisor about our new app:
+
+ sudo supervisorctl reread
+
+You should see a message `helloworld available`. So Supervisor knows about our app, let's actually add it.
+
+ sudo supervisorctl update
+
+Now you should see a message that says something like `helloworld: added process group`. Supervisor is now aware of our hello world app and will make sure it automatically starts up whenever our server reboots. You can check the status of our gunicorn app with:
+
+ sudo supervisorctl status \ No newline at end of file