677a8efa2bbb1f513d9bae6cd8a9b9a8b1339863
[pithos] / docs / source / adminguide.rst
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-setuptools python-sphinx
12   apt-get install python-sqlalchemy 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   cd /pithos
26   python setup.py build_sphinx
27
28 Edit ``/etc/apache2/sites-available/pithos`` (change the ``ServerName`` directive)::
29
30   <VirtualHost *:80>
31     ServerAdmin webmaster@pithos.dev.grnet.gr
32     ServerName pithos.dev.grnet.gr
33
34     DocumentRoot /pithos/htdocs
35     Alias /ui "/var/www/pithos_web_client"
36     Alias /docs "/pithos/docs/build/html"
37
38     <Directory />
39         Options Indexes FollowSymLinks
40         AllowOverride None
41         Order allow,deny
42         Allow from all
43     </Directory>
44
45     RewriteEngine On
46     RewriteRule ^/v(.*) /api/v$1 [PT]
47     RewriteRule ^/public(.*) /api/public$1 [PT]
48     RewriteRule ^/login(.*) https://%{HTTP_HOST}%{REQUEST_URI}
49     RewriteRule ^/admin(.*) https://%{HTTP_HOST}%{REQUEST_URI}
50
51     WSGIScriptAlias /api /pithos/pithos/wsgi/pithos.wsgi
52     # WSGIDaemonProcess pithos
53     # WSGIProcessGroup pithos
54
55     LogLevel warn
56     ErrorLog ${APACHE_LOG_DIR}/pithos.error.log
57     CustomLog ${APACHE_LOG_DIR}/pithos.access.log combined
58   </VirtualHost>
59
60 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)::
61
62   <IfModule mod_ssl.c>
63   <VirtualHost _default_:443>
64     ServerAdmin webmaster@pithos.dev.grnet.gr
65     ServerName pithos.dev.grnet.gr
66
67     DocumentRoot /pithos/htdocs
68     Alias /ui "/var/www/pithos_web_client"
69     Alias /docs "/pithos/docs/build/html"
70
71     <Directory />
72         Options Indexes FollowSymLinks
73         AllowOverride None
74         Order allow,deny
75         Allow from all
76     </Directory>
77
78     RewriteEngine On
79     RewriteRule ^/v(.*) /api/v$1 [PT]
80     RewriteRule ^/public(.*) /api/public$1 [PT]
81     RewriteRule ^/login(.*) /api/login$1 [PT]
82     RewriteRule ^/admin(.*) /api/admin$1 [PT]
83
84     WSGIScriptAlias /api /pithos/pithos/wsgi/pithos.wsgi
85     # WSGIDaemonProcess pithos
86     # WSGIProcessGroup pithos
87
88     ShibConfig /etc/shibboleth/shibboleth2.xml
89     Alias      /shibboleth-sp /usr/share/shibboleth 
90
91     <Location /api/login>
92         AuthType shibboleth
93         ShibRequireSession On
94         ShibUseHeaders On
95         require valid-user
96     </Location>
97
98     LogLevel warn
99     ErrorLog ${APACHE_LOG_DIR}/pithos.error.log
100     CustomLog ${APACHE_LOG_DIR}/pithos.access.log combined
101
102     SSLEngine on
103     SSLCertificateFile    /etc/ssl/certs/pithos.dev.grnet.gr.crt
104     SSLCertificateKeyFile /etc/ssl/private/pithos.dev.grnet.gr.key
105   </VirtualHost>
106   </IfModule>
107
108 Configure and run apache::
109
110   a2enmod ssl
111   a2enmod rewrite
112   a2dissite default
113   a2ensite pithos
114   a2ensite pithos-ssl
115   mkdir /var/www/pithos
116   mkdir /var/www/pithos_web_client
117   /etc/init.d/apache2 restart
118
119 Useful alias to add in ``~/.bashrc``::
120
121   alias pithos-sync='cd /pithos && git pull && python setup.py build_sphinx && /etc/init.d/apache2 restart'
122
123 Shibboleth Setup
124 ----------------
125
126 Install package::
127
128   apt-get install libapache2-mod-shib2
129
130 Setup the files in ``/etc/shibboleth``.
131
132 Add in ``/etc/apache2/sites-available/pithos-ssl``::
133
134         ShibConfig /etc/shibboleth/shibboleth2.xml
135         Alias      /shibboleth-sp /usr/share/shibboleth 
136
137         <Location /api/login>
138                 AuthType shibboleth
139                 ShibRequireSession On
140                 ShibUseHeaders On
141                 require valid-user
142         </Location>
143
144 Configure and run apache::
145
146   a2enmod shib2
147   /etc/init.d/apache2 restart
148   /etc/init.d/shibd restart
149
150 MySQL Setup
151 -----------
152
153 If using MySQL instead of SQLite for the database engine, consider the following.
154
155 Server side::
156
157   apt-get install mysql-server
158
159 Edit ``/etc/mysql/my.cnf`` to allow network connections and restart the server.
160
161 Create database and user::
162
163   CREATE DATABASE pithos;
164   GRANT ALL ON pithos.* TO pithos@localhost IDENTIFIED BY 'password';
165   GRANT ALL ON pithos.* TO pithos@'%' IDENTIFIED BY 'password';
166
167 Client side::
168
169   apt-get install mysql-client
170
171 It helps to create a ``~/.my.cnf`` file, for automatically connecting to the server::
172
173   [client]
174   user = pithos
175   password = 'password'
176   host = pithos-storage.dev.grnet.gr
177
178   [mysql]
179   database = pithos
180
181 PostgreSQL Setup
182 ----------------
183
184 If using PostgreSQL instead of SQLite for the database engine, consider the following.
185
186 Server side::
187
188   apt-get install postgresql
189
190 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.
191
192 Create database and user::
193
194   CREATE DATABASE pithos WITH ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE=template0;
195   CREATE USER pithos WITH PASSWORD 'password';
196   GRANT ALL PRIVILEGES ON DATABASE pithos TO pithos;
197
198 Client side::
199
200   apt-get install postgresql-client
201
202 It helps to create a ``~/.pgpass`` file, for automatically passing the password to the server::
203
204   pithos-storage.dev.grnet.gr:5432:pithos:pithos:password
205
206 Connect with::
207
208   psql -h pithos-storage.dev.grnet.gr -U pithos
209