Statistics
| Branch: | Tag: | Revision:

root / docs / source / adminguide.rst @ 5bc1116c

History | View | Annotate | Download (7.3 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::
21

    
22
  cd /pithos/pithos
23
  python manage.py syncdb
24
  python manage.py migrate im
25
  cd /pithos
26
  python setup.py build_sphinx
27

    
28
It is advised that you create a ``settings.local`` file to place any configuration overrides (at least change ``SECRET_KEY``).
29

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

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

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

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

    
47
    SetEnv no-gzip
48
    SetEnv dont-vary
49

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

    
57
    RequestHeader set X-Forwarded-Protocol "http"
58

    
59
    WSGIScriptAlias /api /pithos/pithos/wsgi/pithos.wsgi
60
    # WSGIDaemonProcess pithos
61
    # WSGIProcessGroup pithos
62

    
63
    LogLevel warn
64
    ErrorLog ${APACHE_LOG_DIR}/pithos.error.log
65
    CustomLog ${APACHE_LOG_DIR}/pithos.access.log combined
66
  </VirtualHost>
67

    
68
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)::
69

    
70
  <IfModule mod_ssl.c>
71
  <VirtualHost _default_:443>
72
    ServerAdmin webmaster@pithos.dev.grnet.gr
73
    ServerName pithos.dev.grnet.gr
74

    
75
    DocumentRoot /pithos/htdocs
76
    Alias /ui "/var/www/pithos_web_client"
77
    Alias /docs "/pithos/docs/build/html"
78

    
79
    <Directory />
80
        Options Indexes FollowSymLinks
81
        AllowOverride None
82
        Order allow,deny
83
        Allow from all
84
    </Directory>
85

    
86
    SetEnv no-gzip
87
    SetEnv dont-vary
88

    
89
    RewriteEngine On
90
    RewriteRule ^/v(.*) /api/v$1 [PT,NE]
91
    RewriteRule ^/public(.*) /api/public$1 [PT,NE]
92
    RewriteRule ^/tools(.*) /api/ui$1 [PT,NE]
93
    RewriteRule ^/im(.*) /api/im$1 [PT,NE]
94
    RewriteRule ^/login(.*) /api/im/login/dummy$1 [PT,NE]
95

    
96
    RequestHeader set X-Forwarded-Protocol "https"
97

    
98
    WSGIScriptAlias /api /pithos/pithos/wsgi/pithos.wsgi
99
    # WSGIDaemonProcess pithos
100
    # WSGIProcessGroup pithos
101

    
102
    LogLevel warn
103
    ErrorLog ${APACHE_LOG_DIR}/pithos.error.log
104
    CustomLog ${APACHE_LOG_DIR}/pithos.access.log combined
105

    
106
    SSLEngine on
107
    SSLCertificateFile    /etc/ssl/certs/pithos.dev.grnet.gr.crt
108
    SSLCertificateKeyFile /etc/ssl/private/pithos.dev.grnet.gr.key
109
  </VirtualHost>
110
  </IfModule>
111

    
112
Add in ``/etc/apache2/mods-available/wsgi.conf``::
113

    
114
  WSGIChunkedRequest On
115

    
116
Configure and run apache::
117

    
118
  a2enmod ssl
119
  a2enmod rewrite
120
  a2dissite default
121
  a2ensite pithos
122
  a2ensite pithos-ssl
123
  mkdir /var/www/pithos
124
  mkdir /var/www/pithos_web_client
125
  /etc/init.d/apache2 restart
126

    
127
Useful alias to add in ``~/.bashrc``::
128

    
129
  alias pithos-sync='cd /pithos && git pull && python setup.py build_sphinx && cd pithos && python manage.py migrate im && /etc/init.d/apache2 restart'
130

    
131
Gunicorn Setup
132
--------------
133

    
134
Add in ``/etc/apt/sources.list``::
135

    
136
  deb http://backports.debian.org/debian-backports squeeze-backports main
137

    
138
Then::
139

    
140
  apt-get update
141
  apt-get -t squeeze-backports install gunicorn
142
  apt-get -t squeeze-backports install python-gevent
143

    
144
Create ``/etc/gunicorn.d/pithos``::
145

    
146
  CONFIG = {
147
   'mode': 'django',
148
   'working_dir': '/pithos/pithos',
149
   'user': 'www-data',
150
   'group': 'www-data',
151
   'args': (
152
        '--bind=[::]:8080',
153
        '--worker-class=egg:gunicorn#gevent',
154
        '--workers=4',
155
        '--log-level=debug',
156
        '/pithos/pithos/settings.py',
157
   ),
158
  }
159

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

    
162
  <Proxy *>
163
    Order allow,deny
164
    Allow from all
165
  </Proxy>
166

    
167
  SetEnv                proxy-sendchunked
168
  SSLProxyEngine        off
169
  ProxyErrorOverride    off
170

    
171
  ProxyPass        /api http://localhost:8080 retry=0
172
  ProxyPassReverse /api http://localhost:8080
173

    
174
Make sure that in ``settings.local``::
175

    
176
  USE_X_FORWARDED_HOST = True
177

    
178
Configure and run::
179

    
180
  /etc/init.d/gunicorn restart
181
  a2enmod proxy
182
  a2enmod proxy_http
183
  /etc/init.d/apache2 restart
184

    
185
If experiencing timeout problems, try adding to ``/etc/gunicorn.d/pithos``::
186

    
187
        ...
188
        '--timeout=43200',
189
        ...
190

    
191
Shibboleth Setup
192
----------------
193

    
194
Install package::
195

    
196
  apt-get install libapache2-mod-shib2
197

    
198
Setup the files in ``/etc/shibboleth``.
199

    
200
Add in ``/etc/apache2/sites-available/pithos-ssl``::
201

    
202
  ShibConfig /etc/shibboleth/shibboleth2.xml
203
  Alias      /shibboleth-sp /usr/share/shibboleth 
204

    
205
  <Location /api/im/login/shibboleth>
206
    AuthType shibboleth
207
    ShibRequireSession On
208
    ShibUseHeaders On
209
    require valid-user
210
  </Location>
211

    
212
Configure and run apache::
213

    
214
  a2enmod shib2
215
  /etc/init.d/apache2 restart
216
  /etc/init.d/shibd restart
217

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

    
220
  eppn # eduPersonPrincipalName
221
  Shib-InetOrgPerson-givenName
222
  Shib-Person-surname
223
  Shib-Person-commonName
224
  Shib-InetOrgPerson-displayName
225
  Shib-EP-Affiliation
226
  Shib-Session-ID
227

    
228
MySQL Setup
229
-----------
230

    
231
If using MySQL instead of SQLite for the database engine, consider the following.
232

    
233
Server side::
234

    
235
  apt-get install mysql-server
236

    
237
Add in ``/etc/mysql/conf.d/pithos.cnf``::
238

    
239
  [mysqld]
240
  sql-mode="NO_AUTO_VALUE_ON_ZERO"
241

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

    
244
Create database and user::
245

    
246
  CREATE DATABASE pithos CHARACTER SET utf8 COLLATE utf8_bin;
247
  GRANT ALL ON pithos.* TO pithos@localhost IDENTIFIED BY 'password';
248
  GRANT ALL ON pithos.* TO pithos@'%' IDENTIFIED BY 'password';
249

    
250
Client side::
251

    
252
  apt-get install mysql-client
253

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

    
256
  [client]
257
  user = pithos
258
  password = 'password'
259
  host = pithos-storage.dev.grnet.gr
260

    
261
  [mysql]
262
  database = pithos
263

    
264
PostgreSQL Setup
265
----------------
266

    
267
If using PostgreSQL instead of SQLite for the database engine, consider the following.
268

    
269
Server side::
270

    
271
  apt-get install postgresql
272

    
273
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.
274

    
275
Create database and user::
276

    
277
  CREATE DATABASE pithos WITH ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE=template0;
278
  CREATE USER pithos WITH PASSWORD 'password';
279
  GRANT ALL PRIVILEGES ON DATABASE pithos TO pithos;
280

    
281
Client side::
282

    
283
  apt-get install postgresql-client
284

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

    
287
  pithos-storage.dev.grnet.gr:5432:pithos:pithos:password
288

    
289
Connect with::
290

    
291
  psql -h pithos-storage.dev.grnet.gr -U pithos
292