minor changes according to JLint
[mir.git] / doc / INSTALL.mir
1 MIR INSTALLATION HOWTO
2
3 Last updated: $Date: 2003/12/03 18:10:45 $
4 ----------------------------------------------------------------
5
6 Here is a short installation-howto of Mir.
7
8
9 prerequisites: 
10
11 - tomcat 4.0.4+ or 3.3 (4.0.3 and below have some bad bugs) 
12   tomcat is available from http://jakarta.apache.org/tomcat/
13 - apache 1.3.x. with mod_jk.so. As far as I can tell the connector for 2.x is
14   still rather undocumented. http://httpd.apache.org
15 - postgres 7.1+
16 - ant (a java-based make) 
17 - jaxp-1.1 (a SAX 2.0 compliant XML parser, comes with ant >= 1.4)
18 - the JAI image framework (Java Advanced Imaging) version 1.1.2 . Get it from 
19   java.sun.com. You need both: JAI and JAI Image I/O. Install those two in
20   the JRE running tomcat.
21
22 - A good reading of Tomcat, Apache and Postgresql documentation if you are not
23   familiar with any of them. The documentation is available at:
24   http://jakarta.apache.org/tomcat/tomcat-4.0-doc/index.html,
25   http://httpd.apache.org/docs/ and http://www.postgresql.org respectively.
26
27 1. checkout the cvs
28
29 CVS LOGIN:
30
31   cvs -d :pserver:anonymous@mir.indymedia.org:/var/lib/cvs login
32         password: anonymous
33
34 CVS CHECKOUT:
35
36         cvs -d :pserver:anonymous@mir.indymedia.org:/var/lib/cvs co -r MIR_1_1 mir
37
38
39 2. customize the config: 
40
41         cd mir/etc
42         cp config.properties-dist config.properties 
43
44 now customize config.properties for your needs.
45
46
47 3. configure the perms.sh file if neccessary -- IMPORTANT! READ THIS!
48 We provide a script that sets all files' and direcories' permissions to
49 a quite reasonable state. This script gets automagically called by
50 ant after compilationl. The most important thing you have to do after
51 compiling Mir is to ensure that the log files -- especially 
52 dbentity.log -- are not readable by users that could compromise 
53 system security, because all passwords and the like will be logged here.
54         
55         cp perms.sh-dist perms.sh
56
57 Now, change the install directory and group in perms.sh
58
59         edit perms.sh 
60
61 4. There is NO step 4!!
62
63 5. compile. For this step, you have to make sure that the TOMCAT_HOME
64 environment variable is set to the root of your tomcat installation.
65 The build.xml compile target will give up if this is not set.
66
67 Do this as root so the permissions script is able to set
68 the permissions and owners correctly.
69
70     ant 
71
72
73 6. Link in the webapps directory of tomcat to the install directory (the 
74 directory is in mir/bin/mir (Here and in the rest of this document,
75 we assume you called the link "Mir", but this could be named anything.)
76         cd ${TOMCAT_HOME}/webapps 
77         ln -s /path/to/mir/bin/mir Mir
78
79 with tomcat 4.0.x, you could dynamically reload and stop the Mir webapp without
80 restarting tomcat by using the "Manager App" with the following url:
81
82 http://localhost:8080/manager/stop?path=/Mir
83
84 This is practical if you are running several installations of mir on one 
85 tomcat or other webapps and can't afford to shutdown all of them.
86 See the tomcat documentation to learn how to enable and use the manager app.
87
88 7. Follow the installation instructions of JAI / JAI Image I/O.
89
90 8a. create a new database 
91 The database name should be the same as in config.properties. Please look at
92 the section "Database.*" to look up the names or change them to your needs. 
93
94 It is wise in terms of system security to use an unprivileged user for this
95 task instead of the superuser. This is because if Mir uses the superuser to
96 connect to the database and anybody manages to find out the password Mir 
97 uses to connect, the attacker can take over the complete database. So, in
98 the following examples, we assume that the database name is "Mir", the
99 database user will be "joe" and the password is "joshua". Please note that
100 this particular password is far from being a good one. Watch "Wargames" for
101 details. =B) 
102
103
104 To access the database as the database superuser, you either have to log in
105 as postgres on Unix level (which we don't recommend because you will need
106 another user to have a login shell and a password which makes system
107 penetration more likely) or you have to tell PostgreSQL with each
108 application call that you want to connect as a specific user. In the 
109 following example we'll create the mir database as postgreSQL user 
110 "pete".
111
112         cd mir/dbscripts
113         su postgres
114         ./createmirdb.sh mir pete joe joshua
115
116 8b. Apply neccessary changes to config.properties
117
118 Please open config.properties and look for the lines that begin with
119 "Database.". The interesting properties are "Username", "Password", "Host"
120 and "Name". Change these properties so that they reflect the settings you
121 used to create the database and the user.
122
123 You should make sure that no copy of config.properties (neither in mir nor
124 in Mir/src nor in Mir/WEB-INF/classes nor in the directory tree you compiled
125 Mir from) is world-readable. Else you wouldn't have to install a password,
126 anyway.
127
128 8c. Setup PostgreSQL so that all localhost connections have to pass a 
129 password
130
131 In /etc/postgresql/pg_hba.conf, change the line with 127.0.0.1 as follows:
132
133 host         all         127.0.0.1     255.0.0.0           password
134
135 This means: All connections from 127.0.0.1 to any database will have to 
136 authenticate themselves with a password. Please refer to the PostgreSQL
137 documentation if you want a different authentication setup. Make sure
138 however that mir can connect to it's database using password authentication.
139
140 9. For now, there's no step 9 either.
141
142 10. Tweak mime-type extensions mappings in etc/web.xml file.
143
144 *** Note the defaults should be o.k for most installations ***
145
146 Add or remove any mime types you wish to support. This is used to figure
147 out the mime-type when (broken browsers?) browsers don't send the mime-type
148 in the content-type header field when uploading a media file. Note add the
149 moment you still have to add these to the media_type SQL table as well which
150 maps the mime-types to the correct mediaHandler class. See the comments in
151 the MirMedia class in javadoc for more details.
152
153 11. restart tomcat 
154
155 12. configure mod_jk 
156
157 There are 2 ways to do this. auto-generation of mod_jk.conf or manula JKMount
158 lines. (rumour has it that Tomcat 4.0.x doesn't support auto-generation, but
159 this is unconfirmed).
160
161 In both examples please note that the JkWorkersFile line only needs to appear
162 once per Apache config.
163
164 Also this assumes that your tomcat installation has it's ajp13 conenctor 
165 turned on. See tomcat's server.xml file and documentation for this. Chances
166 are that it is turned on.
167
168 Method a). The automatic mod_jk.conf method:
169
170 insert the following patch into /etc/apache/httpd.conf. Edit the directories
171 to suit your needs.
172
173 <IfModule mod_jk.c>
174 JkWorkersFile /path/to/tomcat/conf/workers.properties
175 Include /path/to/tomcat/conf/mod_jk.conf-auto
176 </IfModule>
177
178 Do not put any JkMount lines into your httpd.conf!
179
180 If mod_jk.conf-auto doesn't get written or is 0 bytes in size, check your
181 system for file ownership/permissions problems.
182
183 Method b). Manual JKMount lines
184
185 insert the following patch into /etc/apache/httpd.conf. Edit the directories
186 to suit your needs.
187
188 <IfModule mod_jk.c>
189 JkWorkersFile /path/to/tomcat/conf/workers.properties
190 JkMount /Mir ajp13
191 JkMount /Mir/* ajp13
192 </IfModule>
193
194
195 13. configure apache for the static site
196
197 * Make sure that if you are using a non standard character set enconding that 
198   Apache doesn't accidentally send the wrong encoding in the HTTP headers.
199 edit http.conf:
200 * set the document root to the same directory as in the mir config file
201 * enable shtml includes:
202   - add LoadModule includes_module /usr/lib/apache/1.3/mod_include.so
203   - make sure your directory contains "Options Includes"
204 * Determine if you need to modify any apache mime-mappings
205   - The web-server host must recognize the .m3u, .pls and other file extensions
206     and send the proper "audio/x-mpegurl" and "audio/x-scpls" mime-types
207     respectively.  If the web server is apache, it's easy, just
208     add:
209     
210     audio/x-mpegurl                 m3u
211     audio/x-scpl                    pls
212     
213     to the file pointed to by the "TypesConfig" command in your apache config
214     file. Or add and equivalent AddType command to your httpd.conf.  Of course
215     this assumes that the mod_mime is loaded.
216
217 that's it :)
218
219 now the admin-application is accesable via:  
220
221         http://host/Mir/servlet/Mir 
222
223 and the openposting-servlet via  
224         
225         http://host/Mir/servlet/OpenMir
226
227 standard login is admin/indymedia. See the webdb_users SQL table to change/add
228 users or passwords.
229
230
231 SEARCHING
232
233 The Mir code offers no internal search facilities, rather, the design
234 expects the use of an external program to crawl and index the static
235 site.  One (recommended) tool for doing this is htdig
236 (http://htdig.org), which generates static databases of the site
237 content and then accesses those databases through a very fast CGI
238 program written in C.  In the scripts directory, a perl CGI script 
239 which wraps calls to htsearch is provided (scripts/search.pl) which
240 will allow searching based off of media type.  (This is possible
241 because the standard templates will include META keywords like
242 hasAudio, hasVideo, etc.)  
243
244 UPGRADING
245
246 see the UPGRADING.mir file.
247
248 TROUBLESHOOTING
249
250 You can give these a try if anything goes wrong:
251
252 + Restart Tomcat. Especially after compiling the sources Tomcat has to be
253   restarted.
254
255 + Check file permissions and ownership. Try and run perms.sh.
256
257 ----------------------------------------------------------------
258
259 $Date: 2003/12/03 18:10:45 $ - the Mir coders