Statistics
| Branch: | Tag: | Revision:

root / docs / source / adminguide.rst @ 0f8ffac4

History | View | Annotate | Download (7 kB)

1
Administrator Guide
2
===================
3

    
4
Simple Setup
5
------------
6

    
7
Assuming a clean debian squeeze (stable) installation, use the following steps to run the software.
8

    
9
Install packages::
10

    
11
  apt-get install git python-django python-django-south python-setuptools python-sphinx python-httplib2
12
  apt-get install python-sqlalchemy python-mysqldb python-psycopg2
13
  apt-get install apache2 libapache2-mod-wsgi
14

    
15
Get the source::
16

    
17
  cd /
18
  git clone https://code.grnet.gr/git/pithos
19

    
20
Setup the files (choose where to store data in ``settings.py`` and change ``SECRET_KEY``)::
21

    
22
  cd /pithos/pithos
23
  cp settings.py.dist settings.py
24
  python manage.py syncdb
25
  python manage.py schemamigration im --initial
26
  cd /pithos
27
  python setup.py build_sphinx
28

    
29
Edit ``/etc/apache2/sites-available/pithos`` (change the ``ServerName`` directive)::
30

    
31
  <VirtualHost *:80>
32
    ServerAdmin webmaster@pithos.dev.grnet.gr
33
    ServerName pithos.dev.grnet.gr
34

    
35
    DocumentRoot /pithos/htdocs
36
    Alias /ui "/var/www/pithos_web_client"
37
    Alias /docs "/pithos/docs/build/html"
38

    
39
    <Directory />
40
        Options Indexes FollowSymLinks
41
        AllowOverride None
42
        Order allow,deny
43
        Allow from all
44
    </Directory>
45

    
46
    RewriteEngine On
47
    RewriteRule ^/v(.*) /api/v$1 [PT,NE]
48
    RewriteRule ^/public(.*) /api/public$1 [PT,NE]
49
    RewriteRule ^/tools(.*) /api/ui$1 [PT,NE]
50
    RewriteRule ^/im(.*) https://%{HTTP_HOST}%{REQUEST_URI} [NE]
51
    RewriteRule ^/login(.*) https://%{HTTP_HOST}%{REQUEST_URI} [NE]
52

    
53
    WSGIScriptAlias /api /pithos/pithos/wsgi/pithos.wsgi
54
    # WSGIDaemonProcess pithos
55
    # WSGIProcessGroup pithos
56

    
57
    LogLevel warn
58
    ErrorLog ${APACHE_LOG_DIR}/pithos.error.log
59
    CustomLog ${APACHE_LOG_DIR}/pithos.access.log combined
60
  </VirtualHost>
61

    
62
Edit ``/etc/apache2/sites-available/pithos-ssl`` (assuming files in ``/etc/ssl/private/pithos.dev.grnet.gr.key`` and ``/etc/ssl/certs/pithos.dev.grnet.gr.crt`` - change the ``ServerName`` directive)::
63

    
64
  <IfModule mod_ssl.c>
65
  <VirtualHost _default_:443>
66
    ServerAdmin webmaster@pithos.dev.grnet.gr
67
    ServerName pithos.dev.grnet.gr
68

    
69
    DocumentRoot /pithos/htdocs
70
    Alias /ui "/var/www/pithos_web_client"
71
    Alias /docs "/pithos/docs/build/html"
72

    
73
    <Directory />
74
        Options Indexes FollowSymLinks
75
        AllowOverride None
76
        Order allow,deny
77
        Allow from all
78
    </Directory>
79

    
80
    RewriteEngine On
81
    RewriteRule ^/v(.*) /api/v$1 [PT,NE]
82
    RewriteRule ^/public(.*) /api/public$1 [PT,NE]
83
    RewriteRule ^/tools(.*) /api/ui$1 [PT,NE]
84
    RewriteRule ^/im(.*) /api/im$1 [PT,NE]
85
    RewriteRule ^/login(.*) /api/im/login/dummy$1 [PT,NE]
86

    
87
    WSGIScriptAlias /api /pithos/pithos/wsgi/pithos.wsgi
88
    # WSGIDaemonProcess pithos
89
    # WSGIProcessGroup pithos
90

    
91
    LogLevel warn
92
    ErrorLog ${APACHE_LOG_DIR}/pithos.error.log
93
    CustomLog ${APACHE_LOG_DIR}/pithos.access.log combined
94

    
95
    SSLEngine on
96
    SSLCertificateFile    /etc/ssl/certs/pithos.dev.grnet.gr.crt
97
    SSLCertificateKeyFile /etc/ssl/private/pithos.dev.grnet.gr.key
98
  </VirtualHost>
99
  </IfModule>
100

    
101
Add in ``/etc/apache2/mods-available/wsgi.conf``::
102

    
103
  WSGIChunkedRequest On
104

    
105
Configure and run apache::
106

    
107
  a2enmod ssl
108
  a2enmod rewrite
109
  a2dissite default
110
  a2ensite pithos
111
  a2ensite pithos-ssl
112
  mkdir /var/www/pithos
113
  mkdir /var/www/pithos_web_client
114
  /etc/init.d/apache2 restart
115

    
116
Useful alias to add in ``~/.bashrc``::
117

    
118
  alias pithos-sync='cd /pithos && git pull && python setup.py build_sphinx && /etc/init.d/apache2 restart'
119

    
120
Gunicorn Setup
121
--------------
122

    
123
Add in ``/etc/apt/sources.list``::
124

    
125
  deb http://backports.debian.org/debian-backports squeeze-backports main
126

    
127
Then::
128

    
129
  apt-get update
130
  apt-get -t squeeze-backports install gunicorn
131
  apt-get -t squeeze-backports install python-gevent
132

    
133
Create ``/etc/gunicorn.d/pithos``::
134

    
135
  CONFIG = {
136
   'mode': 'django',
137
   'working_dir': '/pithos/pithos',
138
   'user': 'www-data',
139
   'group': 'www-data',
140
   'args': (
141
        '--bind=[::]:8080',
142
        '--worker-class=egg:gunicorn#gevent',
143
        '--workers=4',
144
        '--log-level=debug',
145
        '/pithos/pithos/settings.py',
146
   ),
147
  }
148

    
149
Replace the ``WSGI*`` directives in ``/etc/apache2/sites-available/pithos`` and ``/etc/apache2/sites-available/pithos-ssl`` with::
150

    
151
  <Proxy *>
152
    Order allow,deny
153
    Allow from all
154
  </Proxy>
155

    
156
  SetEnv                proxy-sendchunked
157
  SSLProxyEngine        off
158
  ProxyErrorOverride    off
159

    
160
  ProxyPass        /api http://localhost:8080 retry=0
161
  ProxyPassReverse /api http://localhost:8080
162

    
163
Make sure that in ``settings.py``::
164

    
165
  USE_X_FORWARDED_HOST = True
166

    
167
Configure and run::
168

    
169
  /etc/init.d/gunicorn restart
170
  a2enmod proxy
171
  a2enmod proxy_http
172
  /etc/init.d/apache2 restart
173

    
174
Shibboleth Setup
175
----------------
176

    
177
Install package::
178

    
179
  apt-get install libapache2-mod-shib2
180

    
181
Setup the files in ``/etc/shibboleth``.
182

    
183
Add in ``/etc/apache2/sites-available/pithos-ssl``::
184

    
185
  ShibConfig /etc/shibboleth/shibboleth2.xml
186
  Alias      /shibboleth-sp /usr/share/shibboleth 
187

    
188
  <Location /api/im/login/shibboleth>
189
    AuthType shibboleth
190
    ShibRequireSession On
191
    ShibUseHeaders On
192
    require valid-user
193
  </Location>
194

    
195
Configure and run apache::
196

    
197
  a2enmod shib2
198
  /etc/init.d/apache2 restart
199
  /etc/init.d/shibd restart
200

    
201
The following tokens should be available at the destination, after passing through the apache module::
202

    
203
  eppn # eduPersonPrincipalName
204
  Shib-InetOrgPerson-givenName
205
  Shib-Person-surname
206
  Shib-Person-commonName
207
  Shib-InetOrgPerson-displayName
208
  Shib-EP-Affiliation
209
  Shib-Session-ID
210

    
211
MySQL Setup
212
-----------
213

    
214
If using MySQL instead of SQLite for the database engine, consider the following.
215

    
216
Server side::
217

    
218
  apt-get install mysql-server
219

    
220
Add in ``/etc/mysql/conf.d/pithos.cnf``::
221

    
222
  [mysqld]
223
  sql-mode="NO_AUTO_VALUE_ON_ZERO"
224

    
225
Edit ``/etc/mysql/my.cnf`` to allow network connections and restart the server.
226

    
227
Create database and user::
228

    
229
  CREATE DATABASE pithos CHARACTER SET utf8 COLLATE utf8_bin;
230
  GRANT ALL ON pithos.* TO pithos@localhost IDENTIFIED BY 'password';
231
  GRANT ALL ON pithos.* TO pithos@'%' IDENTIFIED BY 'password';
232

    
233
Client side::
234

    
235
  apt-get install mysql-client
236

    
237
It helps to create a ``~/.my.cnf`` file, for automatically connecting to the server::
238

    
239
  [client]
240
  user = pithos
241
  password = 'password'
242
  host = pithos-storage.dev.grnet.gr
243

    
244
  [mysql]
245
  database = pithos
246

    
247
PostgreSQL Setup
248
----------------
249

    
250
If using PostgreSQL instead of SQLite for the database engine, consider the following.
251

    
252
Server side::
253

    
254
  apt-get install postgresql
255

    
256
Edit ``/etc/postgresql/8.4/main/postgresql.conf`` and ``/etc/postgresql/8.4/main/pg_hba.conf`` to allow network connections and restart the server.
257

    
258
Create database and user::
259

    
260
  CREATE DATABASE pithos WITH ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE=template0;
261
  CREATE USER pithos WITH PASSWORD 'password';
262
  GRANT ALL PRIVILEGES ON DATABASE pithos TO pithos;
263

    
264
Client side::
265

    
266
  apt-get install postgresql-client
267

    
268
It helps to create a ``~/.pgpass`` file, for automatically passing the password to the server::
269

    
270
  pithos-storage.dev.grnet.gr:5432:pithos:pithos:password
271

    
272
Connect with::
273

    
274
  psql -h pithos-storage.dev.grnet.gr -U pithos
275