<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Server_setup</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>Recent changes to Server_setup</description><atom:link href="https://sourceforge.net/p/labhamster/wiki/Server_setup/feed" rel="self"/><language>en</language><lastBuildDate>Thu, 22 Mar 2012 21:44:01 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/labhamster/wiki/Server_setup/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v18 
+++ v19 
@@ -207,21 +207,56 @@
 
 ... and then steer your browser to the IP address of your host + /admin and Django should greet you with a (unformatted, more on that below) login. 
 
-8.1 Troubleshooting Database access
+
+8.1 Configure serving of static media (including page templates)
+------------------------------------------------------------------
+
+Locate the admin media files of your local django installation:
+
+    sudo updatedb
+    locate base_site.html
+
+Should bring up a folder like this:
+
+    /usr/share/pyshared/django/contrib/admin/...
+
+The media folder within contains static page elements needed for the django admin application. We can use apache to serve these files directly. First link this folder into /var/www:
+
+    sudo ln -s /usr/share/pyshared/django/contrib/admin/media /var/www
+
+Edit /etc/apache2/sites-available/default:
+
+    Alias /media/ /var/www/media/
+
+    WSGIScriptAlias / /home/django/py/labhamsterproject/config/django.wsgi
+    &lt;Directory /home/django/py/labhamsterproject/labhamster&gt;
+	   Order deny,allow
+	   Allow from all
+    &lt;/Directory&gt;
+
+Note, the only new thing is the first line. Ensure that labhamsterproject/settings_local.py contains the following setting:
+
+    ADMIN_MEDIA_PREFIX = '/media/'
+
+... restart apache and verify that the Django layout is fine.
+
+
+8.2 Troubleshooting Database access
 --------------------------------------
 
 In practise, on ubuntu-server, I received an ugly OperationalError: complaining that the database could not be accessed by the user. Read more about postgresqp authentication issues here:
 http://www.depesz.com/2007/10/04/ident/
 
 The problem is resolved by editing pg_hba.conf (located in /etc/postgresql/9.1/main) and adding a line right after the first "local" statement:
 
     # Database administrative login by Unix domain socket
     local   all             postgres                                peer
     ## customization for django user
     local   labhamster      all                                     trust
 
 This basically means that all users arriving from within the server (rather than through TCP/IP from outside) can use the labhamster database without password authentification. Now restart postgrespql and apache:
 
     sudo /etc/init.d/postgresql restart
     sudo apache2ctl restart
+
 
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 21:44:01 -0000</pubDate><guid>https://sourceforge.nete5633bec43a927ef80bd53ad4b1e4247884e9bc3</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v17 
+++ v18 
@@ -208,17 +208,17 @@
 ... and then steer your browser to the IP address of your host + /admin and Django should greet you with a (unformatted, more on that below) login. 
 
 8.1 Troubleshooting Database access
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
+--------------------------------------
+
 In practise, on ubuntu-server, I received an ugly OperationalError: complaining that the database could not be accessed by the user. Read more about postgresqp authentication issues here:
 http://www.depesz.com/2007/10/04/ident/
 
 The problem is resolved by editing pg_hba.conf (located in /etc/postgresql/9.1/main) and adding a line right after the first "local" statement:
 
-     # Database administrative login by Unix domain socket
-     local   all             postgres                                peer
-     ## customization for django user
-     local   labhamster      all                                     trust
+    # Database administrative login by Unix domain socket
+    local   all             postgres                                peer
+    ## customization for django user
+    local   labhamster      all                                     trust
 
 This basically means that all users arriving from within the server (rather than through TCP/IP from outside) can use the labhamster database without password authentification. Now restart postgrespql and apache:
 
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 20:25:32 -0000</pubDate><guid>https://sourceforge.nete5b79deb9a9e84dbd6e608866c564e5043bb7ce2</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v16 
+++ v17 
@@ -201,3 +201,27 @@
 
 (This should go after the &lt;Directory /var/www&gt; ... &lt;/Directory&gt; section.)
 
+In theory this would be it. So you can restart apache:
+
+    sudo apache2ctl restart
+
+... and then steer your browser to the IP address of your host + /admin and Django should greet you with a (unformatted, more on that below) login. 
+
+8.1 Troubleshooting Database access
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In practise, on ubuntu-server, I received an ugly OperationalError: complaining that the database could not be accessed by the user. Read more about postgresqp authentication issues here:
+http://www.depesz.com/2007/10/04/ident/
+
+The problem is resolved by editing pg_hba.conf (located in /etc/postgresql/9.1/main) and adding a line right after the first "local" statement:
+
+     # Database administrative login by Unix domain socket
+     local   all             postgres                                peer
+     ## customization for django user
+     local   labhamster      all                                     trust
+
+This basically means that all users arriving from within the server (rather than through TCP/IP from outside) can use the labhamster database without password authentification. Now restart postgrespql and apache:
+
+    sudo /etc/init.d/postgresql restart
+    sudo apache2ctl restart
+
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 20:24:40 -0000</pubDate><guid>https://sourceforge.net15643e8900e8164195f77386087287f1743fe047</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v15 
+++ v16 
@@ -177,16 +177,18 @@
 -----------------------------
 
 create a configuration file for mod_wsgi in labhamsterproject/config/:
+
     import os
     import sys
     sys.path += ['/home/django/py']
 
     os.environ['DJANGO_SETTINGS_MODULE'] = 'labhamsterproject.settings_local'
 
     import django.core.handlers.wsgi
     application = django.core.handlers.wsgi.WSGIHandler()
 
-Edit the apache config file /etc/apache2/sites-available/default and insert the following block into the VirtualHost:80 section
+
+Edit the apache config file /etc/apache2/sites-available/default and insert the following block into the VirtualHost:80 section:
 
 	## configuration for Django:
 	WSGIScriptAlias / /home/django/py/labhamsterproject/config/django.wsgi
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 19:32:15 -0000</pubDate><guid>https://sourceforge.netc4d9409f28c7fae1bd4fd9c266e4375e7ef35a7d</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v14 
+++ v15 
@@ -176,7 +176,7 @@
 8. Setup Apache / ModWSGI
 -----------------------------
 
-create a configuration file for mod_wsgi in labhamsterproject/config/
+create a configuration file for mod_wsgi in labhamsterproject/config/:
     import os
     import sys
     sys.path += ['/home/django/py']
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 19:31:48 -0000</pubDate><guid>https://sourceforge.net9354f08b317668b3b270d065a98f3a50932c83fd</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v13 
+++ v14 
@@ -177,7 +177,6 @@
 -----------------------------
 
 create a configuration file for mod_wsgi in labhamsterproject/config/
-
     import os
     import sys
     sys.path += ['/home/django/py']
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 19:31:29 -0000</pubDate><guid>https://sourceforge.net70814e8dd63d9280fdb573a308412a2e13478699</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v12 
+++ v13 
@@ -176,18 +176,18 @@
 8. Setup Apache / ModWSGI
 -----------------------------
 
-create a configuration file for mod_wsgi in labhamsterproject/config/::
-
+create a configuration file for mod_wsgi in labhamsterproject/config/
+
     import os
     import sys
     sys.path += ['/home/django/py']
 
     os.environ['DJANGO_SETTINGS_MODULE'] = 'labhamsterproject.settings_local'
 
     import django.core.handlers.wsgi
     application = django.core.handlers.wsgi.WSGIHandler()
 
-Edit the apache config file /etc/apache2/sites-available/default and insert the following block into the VirtualHost:80 section::
+Edit the apache config file /etc/apache2/sites-available/default and insert the following block into the VirtualHost:80 section
 
 	## configuration for Django:
 	WSGIScriptAlias / /home/django/py/labhamsterproject/config/django.wsgi
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 19:31:10 -0000</pubDate><guid>https://sourceforge.net7aa4ebfec4403b381ba91666298532a3f9ccb656</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v11 
+++ v12 
@@ -130,46 +130,73 @@
 In this setup, the database will be accessed with a user-role that has the same name and password as the unix user who created the database. That's perhaps not ideal.
 
 
-8. Install the labhamster project
+7. Install the labhamster project
 ----------------------------------
 
 Login as 'django' and then in /home/django:
 
     make py
     cd py
     svn checkout svn://svn.code.sf.net/p/labhamster/code/trunk labhamsterproject
         A   labhamsterproject/manage.py
         ...
         Checked out revision 2.
 
 Adapt your python / django environment by adding the following lines to ~/.zshenv
 
     export PYTHONPATH=~/py:$PYTHONPATH
-    export DJANGO_SETTINGS_MODULE=labhamster.settings
+    export DJANGO_SETTINGS_MODULE=labhamsterproject.settings_local
 
 Link the labhamster app into the PYTHONPATH
 
     cd py
     ln -s labhamsterproject/labhamster .
 
-Adapt the database settings of the labhamster app. Edit the file settings.py. The following worked for me:
+Adapt the database settings of the labhamster app. Create a copy of settings.py and name it settings_local.py. Then edit the file settings.py. The following worked for me:
 
     DATABASES = {'default': 
              {'ENGINE': 'django.db.backends.postgresql_psycopg2',
              'NAME': 'labhamster',
              'USER': 'django',
              'PASSWORD': 'insert_user_password',
              'HOST': '',
              'PORT': ''}}
 
 Now create django databases: 
 
     python manage.py syncdb
 
 Test the setup using the development server:
 
     python manage.py runserver put.your.vm.ip.here:8000
 
 replacing put.your.vm.ip.here by the IP address of your VM (see ifconfig). You can now access the django web server at put.your.vm.ip.here:8000/admin
 
+
+8. Setup Apache / ModWSGI
+-----------------------------
+
+create a configuration file for mod_wsgi in labhamsterproject/config/::
+
+    import os
+    import sys
+    sys.path += ['/home/django/py']
+
+    os.environ['DJANGO_SETTINGS_MODULE'] = 'labhamsterproject.settings_local'
+
+    import django.core.handlers.wsgi
+    application = django.core.handlers.wsgi.WSGIHandler()
+
+Edit the apache config file /etc/apache2/sites-available/default and insert the following block into the VirtualHost:80 section::
+
+	## configuration for Django:
+	WSGIScriptAlias / /home/django/py/labhamsterproject/config/django.wsgi
+
+	&lt;Directory /home/django/py/labhamsterproject/labhamster&gt;
+		   Order deny,allow
+		   Allow from all
+	&lt;/Directory&gt;
+	## end of custom config
+
+(This should go after the &lt;Directory /var/www&gt; ... &lt;/Directory&gt; section.)
 
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 22 Mar 2012 19:30:28 -0000</pubDate><guid>https://sourceforge.netb7bd848d1c1b9d2544b0ece3b77177ee4c9a997b</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v10 
+++ v11 
@@ -161,3 +161,15 @@
              'PASSWORD': 'insert_user_password',
              'HOST': '',
              'PORT': ''}}
+
+Now create django databases: 
+
+    python manage.py syncdb
+
+Test the setup using the development server:
+
+    python manage.py runserver put.your.vm.ip.here:8000
+
+replacing put.your.vm.ip.here by the IP address of your VM (see ifconfig). You can now access the django web server at put.your.vm.ip.here:8000/admin
+
+
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 15 Mar 2012 21:48:03 -0000</pubDate><guid>https://sourceforge.net2fbdab17f3d38029c6978473b322ee42b5b527d5</guid></item><item><title>WikiPage Server_setup modified by Raik Gruenberg</title><link>https://sourceforge.net/p/labhamster/wiki/Server_setup/</link><description>&lt;pre&gt;--- v9 
+++ v10 
@@ -97,11 +97,67 @@
 --------------------------------
 
     sudo apt-get install python-setuptools postgresql libapache2-mod-wsgi 
-    sudo apt-get install python-psycopg2 python-django
-
-
-5. Setup PostgresQL Database
-------------------------------
-
-
-
+    sudo apt-get install postgresql-client
+    sudo apt-get install python-psycopg2 python-django python-django-south
+
+
+6. Create database users/roles
+--------------------------------
+
+Create a database user for your current login and create an empty database for django:
+
+    sudo -u postgres createuser -s $USER
+    createdb labhamster
+
+Verify database setup:
+
+    psql -d labhamster
+    postgres=# \l
+    postgres=# \du
+
+This will list databases and users with their permissions.
+
+Configure postgresql, edit /etc/postgresql/9.1/main/postgresql.conf and uncomment two lines:
+
+    listen_addresses = '*'
+
+    password_encryption = on
+
+Restart Database
+
+    sudo /etc/init.d/postgresql restart
+
+In this setup, the database will be accessed with a user-role that has the same name and password as the unix user who created the database. That's perhaps not ideal.
+
+
+8. Install the labhamster project
+----------------------------------
+
+Login as 'django' and then in /home/django:
+
+    make py
+    cd py
+    svn checkout svn://svn.code.sf.net/p/labhamster/code/trunk labhamsterproject
+        A   labhamsterproject/manage.py
+        ...
+        Checked out revision 2.
+
+Adapt your python / django environment by adding the following lines to ~/.zshenv
+
+    export PYTHONPATH=~/py:$PYTHONPATH
+    export DJANGO_SETTINGS_MODULE=labhamster.settings
+
+Link the labhamster app into the PYTHONPATH
+
+    cd py
+    ln -s labhamsterproject/labhamster .
+
+Adapt the database settings of the labhamster app. Edit the file settings.py. The following worked for me:
+
+    DATABASES = {'default': 
+             {'ENGINE': 'django.db.backends.postgresql_psycopg2',
+             'NAME': 'labhamster',
+             'USER': 'django',
+             'PASSWORD': 'insert_user_password',
+             'HOST': '',
+             'PORT': ''}}
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raik Gruenberg</dc:creator><pubDate>Thu, 15 Mar 2012 21:21:51 -0000</pubDate><guid>https://sourceforge.netaae3129855af5866a1570d73f2cb487f9c7cc466</guid></item></channel></rss>