Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 = Installation Steps =
6
7 {{error}}
8 The Tomcat project has brought a change in the [[way they handle ##RequestDispatcher##>>https://bz.apache.org/bugzilla/show_bug.cgi?id=59317]] which has caused [[regressions in XWiki>>https://jira.xwiki.org/browse/XWIKI-13556]] for some versions of Tomcat. Thus you should **not** use the following Tomcat versions:
9
10 * >= 9.0.0.M5 and < 9.0.0.M10 for the 9.0.x branch (fixed in 9.0.0.M10)
11 * >= 8.5.1 and < 8.5.5 for the 8.5.x branch (fixed in 8.5.5)
12 * >= 8.0.34 and < 8.0.37 for the 8.0.x branch (fixed in 8.0.37)
13 * >= 7.0.70 and < 7.0.71 for the 7.0.x branch (fixed in 7.0.71)
14
15 There is an important Classloader related bug in 8.0.32 which makes impossible to use the code macro or write Python scripts so you should avoid this version if possible. See https://bz.apache.org/bugzilla/show_bug.cgi?id=58999.
16 {{/error}}
17
18 * Download and install [[Tomcat>>http://tomcat.apache.org/]]. There are plenty of ways to install Tomcat, refer to the Tomcat site for more information. Let's call ##TOMCAT_HOME## the directory where it's installed.
19 ** XWiki 12.0+ requires a Tomcat version >= 8 since it requires Servlet 3.1+
20 ** Older versions of XWiki require a Tomcat version >= 7 since it requires Servlet 3.0+
21 * Make sure you [[give enough memory to Java>>platform:AdminGuide.InstallationTomcat#HOutOfMemoryError]] since by default Tomcat is not configured with enough memory for XWiki.
22 * Edit the ##conf/server.xml## file to set the UTF-8 encoding:(((
23 {{code}}
24 <Connector port="8080" ... URIEncoding="UTF-8"/>
25 {{/code}}
26 )))
27 * Extract the [[XWiki WAR>>xwiki:Main.Download]] into a directory named ##xwiki## in ##TOMCAT_HOME/webapps/##
28 * Open ##TOMCAT_HOME/webapps/xwiki/WEB-INF/xwiki.properties## files and [[configure a permanent directory>>platform:AdminGuide.Configuration#HConfiguringDirectories]]
29 * Start Tomcat
30 * When Tomcat has opened go to your wiki by accessing [[http:~~/~~/localhost:8080/xwiki/bin/view/Main/>>http://localhost:8080/xwiki/bin/view/Main/]]
31 * NOTE - if you have issues with maximum cache size - In your ##$CATALINA_BASE/conf/context.xml## add the following content before ##</Context>##:(((
32 {{code}}
33 <Resources cachingAllowed="true" cacheMaxSize="100000" />
34 {{/code}}
35 )))
36
37 == Activate headless mode ==
38
39 If you're operating XWiki on a Linux server with no X11 libraries installed you have to enable headless mode for your Tomcat installation. Sometimes this is also needed on Windows platforms. Typical exceptions are:
40
41 * ##Exception: Could not initialize class sun.awt.X11.XToolkit##
42 * ##java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable##
43
44 * On Linux create a file ##///TOMCAT_HOME///bin/setenv.sh## and insert the following code:(((
45 {{code}}
46 #!/bin/sh
47 export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"
48 {{/code}}
49 )))
50 * On Windows create a file ##///TOMCAT_HOME///bin/setenv.bat## and insert the following code:(((
51 {{code}}
52 set JAVA_OPTS=%JAVA_OPTS% -Djava.awt.headless=true
53 {{/code}}
54 )))
55 * When running as a Windows service the ##setenv.bat## is not working. See registry ##HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\//FOOBAR//\Parameters\Java## for similar settings.
56
57 == Optional configuration ==
58
59 * Edit your ##conf/server.xml## to enable gzip compression: {{code}}<Connector port="8080" ... compression="on" compressionMinSize="2048" compressableMimeType="text/html,text/xml,text/css,text/javascript,application/x-javascript"/>{{/code}}
60 * If you want to modify the port on which Tomcat will run, edit ##//TOMCAT_HOME///conf/server.xml/##. Search for ##8080## (sometimes ##8180## if you are under Linux) and replace with the port value you wish to use.
61 * It is possible to setup a Tomcat Java Server as a UNIX Daemon - JSVC. Just follow [[these instructions>>http://www.malisphoto.com/tips/tomcatonosx.html?#Anchor-JSVC||rel="noopener noreferrer" target="new"]]. The only reason to make Tomcat a daemon is to make it runnable on the 80th port, which can be replaced by using NginX as a proxy on the 80th port and then forwarding to Tomcat to the 8080th port.
62
63 == Policy configuration ==
64
65 For those who activate the security manager for Tomcat, add this portion of code to the end of your ##conf/catalina.policy## file from your Tomcat installation. You can adapt the code for the available installations of OpenOffice/LibreOffice on your server and for different databases :
66
67 {{code}}
68 grant codeBase "file:${catalina.base}/webapps/xwiki/WEB-INF/lib/-" {
69 // for mySQL connection
70 permission java.net.SocketPermission "127.0.0.1:3306", "connect,resolve";
71
72 // XWiki must have access to all properties in read/write
73 permission java.util.PropertyPermission "*", "read, write";
74
75 // Generic detected permissions
76 permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
77 permission java.lang.RuntimePermission "createClassLoader";
78 permission java.lang.RuntimePermission "setContextClassLoader";
79 permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.loader";
80 permission java.lang.RuntimePermission "accessDeclaredMembers";
81 permission java.lang.RuntimePermission "getenv.ProgramFiles";
82 permission java.lang.RuntimePermission "getenv.APPDATA";
83 permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
84 permission java.lang.RuntimePermission "getClassLoader";
85 permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.connector";
86 permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.util.threads";
87 permission java.lang.RuntimePermission "reflectionFactoryAccess";
88 permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jmx.interceptor";
89 permission java.lang.RuntimePermission "accessClassInPackage.com.sun.jmx.mbeanserver";
90 permission java.lang.RuntimePermission "modifyThread";
91 permission java.lang.RuntimePermission "getProtectionDomain";
92
93 // JAXB permissions
94 permission javax.xml.bind.JAXBPermission "setDatatypeConverter";
95
96 // Serialization related permissions
97 permission java.io.SerializablePermission "allowSerializationReflection";
98 permission java.io.SerializablePermission "creator";
99 permission java.io.SerializablePermission "enableSubclassImplementation";
100
101 // Internal resources access permissions
102 permission java.io.FilePermission "synonyms.txt", "read";
103 permission java.io.FilePermission "lang/synonyms_en.txt", "read";
104 permission java.io.FilePermission "quartz.properties", "read";
105 permission java.io.FilePermission "/templates/-", "read";
106 permission java.io.FilePermission "/skins/-", "read";
107 permission java.io.FilePermission "/resources/-", "read";
108
109 // MBean related permissions
110 permission javax.management.MBeanServerPermission "createMBeanServer";
111 permission javax.management.MBeanPermission "*", "registerMBean";
112 permission javax.management.MBeanPermission "*", "unregisterMBean";
113 permission javax.management.MBeanTrustPermission "register";
114 permission javax.management.MBeanPermission "-#-[-]", "queryNames";
115 permission javax.management.MBeanServerPermission "findMBeanServer";
116
117 // LibreOffice/OpenOffice related permissions
118 permission java.io.FilePermission "/opt/openoffice.org3/program/soffice.bin", "read";
119 permission java.io.FilePermission "/opt/libreoffice/program/soffice.bin", "read";
120 permission java.io.FilePermission "/usr/lib/openoffice/program/soffice.bin", "read";
121 permission java.io.FilePermission "/usr/lib/libreoffice/program/soffice.bin", "read";
122
123 // Allow file storage directory reading - for directory and everything underneath
124 // This is dependent on the setting of environment.permanentDirectory in xwiki.properties
125 permission java.io.FilePermission "${catalina.base}${file.separator}xwikidata${file.separator}", "read,write,delete";
126 permission java.io.FilePermission "${catalina.base}${file.separator}xwikidata${file.separator}-", "read,write,delete";
127
128 // Allow file storage directory reading - temporary directory and everything underneath
129 // This is dependent on the setting of environment.temporaryDirectory in xwiki.properties.
130 permission java.io.FilePermission "${catalina.base}${file.separator}temp${file.separator}", "read,write,delete";
131 permission java.io.FilePermission "${catalina.base}${file.separator}temp${file.separator}-", "read,write,delete";
132 };
133 {{/code}}
134
135 Please note that this policy configuration file have been tested on CentOS 5.9 with Sun JDK 1.7.0u21 on Tomcat 7.0.40 with XWiki 5.0.1 installed.
136
137 == Using Nginx as a reverse-proxy for Tomcat (http/https) ==
138
139 For a [[variety of reasons>>https://en.wikipedia.org/wiki/Reverse_proxy||rel="__blank"]], it is not ideal to allow users to connect directly to tomcat. A popular choice for a reverse-proxy web server is [[Nginx>>http://wiki.nginx.org/Main||rel="__blank"]]. These instructions will walk through a very basic deployment of nginx acting as a reverse-proxy for the tomcat XWiki application.
140
141 After a typical XWiki installation XWiki will be running on ##http:~/~/localhost:8080/xwiki##. Ultimately we will want to access XWiki via ##http:~/~/mydomain.com## on a standard http (80) or https (443) port. To accomplish this for unsecure http traffic, the following basic config file gets us started.
142
143 === http (unsecure) ===
144
145 * create this file ##/etc/nginx/conf.d/tomcat.conf##
146 * put the following code inside:(((
147 {{code}}
148 server {
149 listen 80;
150 server_name mydomain.com;
151
152 # Normally root should not be accessed, however, root should not serve files that might compromise the security of your server.
153 root /var/www/html;
154
155 location / {
156 # All "root" requests will have /xwiki appended AND redirected to mydomain.com
157 rewrite ^ $scheme://$server_name/xwiki$request_uri? permanent;
158 }
159
160 location ^~ /xwiki {
161 # If path starts with /xwiki - then redirect to backend: XWiki application in Tomcat
162 # Read more about proxy_pass: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
163 proxy_pass http://localhost:8080;
164 proxy_set_header X-Real-IP $remote_addr;
165 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
166 proxy_set_header Host $http_host;
167 proxy_set_header X-Forwarded-Proto $scheme;
168 }
169 }
170 {{/code}}
171 )))
172 * restart nginx
173
174 Now all ##http:~/~/mydomain.com/*## requests will lead to the XWiki application. Please note that these settings are basic. For more flexible solutions please refer to [[the Nginx documentation>>http://wiki.nginx.org/Main||rel="__blank"]].
175
176 === https (secure) ===
177
178 There are many guides on how to create a secure configuration of nginx. To get started:
179
180 * [[Strong SSL Security on nginx>>https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html||rel="__blank"]]
181 * [[How To Secure Nginx With LetsEncrypt on Ubuntu 16.04>>https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04||rel="__blank"]]
182
183 The following config assumes you are using LetsEncrypt and that your XWiki is hosted on ##http:~/~/localhost:8080/##. This config will redirect all unsecure requests to https:~/~/ and set the correct proxy headers for a secure nginx+tomcat setup.
184
185 First, you will need to add the following config to tomcat's ##server.xml## (located at ##/etc/tomcat8/server.xml## on Ubuntu 16.04). The first line should already be in the file, I include it to give you something to search for (that line is located on line 108 in the Ubuntu 16.04 tomcat8 package). This will help tomcat find your proxy headers.
186
187 (((
188 {{code}}
189 <Engine name="Catalina" defaultHost="localhost">
190 <Valve className="org.apache.catalina.valves.RemoteIpValve"
191 internalProxies="127\.0\.[0-1]\.1"
192 remoteIpHeader="x-forwarded-for"
193 requestAttributesEnabled="true"
194 protocolHeader="x-forwarded-proto"
195 protocolHeaderHttpsValue="https"/>
196 {{/code}}
197 )))
198
199 Next, add the following nginx config file to your nginx config folder, replacing ##wiki.yourdomain.com## with your actual domain info:
200
201 (((
202 {{code}}
203 server {
204 listen 80;
205 server_name wiki.yourdomain.com;
206
207 location ~ /.well-known {
208 allow all;
209 }
210
211 rewrite ^ https://$server_name$request_uri? permanent;
212
213 access_log /var/log/nginx-xwiki/access.log;
214 error_log /var/log/nginx-xwiki/error.log;
215
216 }
217
218 server {
219 listen 443;
220 server_name wiki.yourdomain.com;
221
222 root /var/www/html;
223
224 ssl on;
225 ssl_certificate /etc/letsencrypt/live/wiki.yourdomain.com/fullchain.pem;
226 ssl_certificate_key /etc/letsencrypt/live/wiki.yourdomain.com/privkey.pem;
227
228 access_log /var/log/nginx-xwiki/access_ssl.log;
229 error_log /var/log/nginx-xwiki/error_ssl.log;
230
231 location / {
232 proxy_set_header Host $http_host;
233 proxy_set_header X-Real-IP $remote_addr;
234 proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
235 proxy_set_header X-Forwarded-Proto $scheme;
236 proxy_set_header X-Scheme $scheme;
237 proxy_redirect off;
238 if (!-f $request_filename) {
239 proxy_pass http://127.0.0.1:8080;
240 break;
241 }
242 }
243
244 location ~ /.well-known {
245 allow all;
246 }
247 }
248 {{/code}}
249 )))
250
251 For more background on this config, see the discussion on this ticket: [[XWIKI-13963>>http://jira.xwiki.org/browse/XWIKI-13963||rel="__blank"]].
252
253 === Proxying and tunnels ===
254
255 This proxy methods brings remote connections to local connection. This is complementary to SSH-tunneling which is easily done on port 8080 and can be used to test development servers.
256
257 For example, if you are running an XWiki on port 80 on your laptop while running the NGinx (or Apache) on a server where it is accessible as ##{{{https://wiki.yourdomain.com}}}##, you can make your XWiki acessible with this URL:
258
259 * First make sure that the port 8080 is not in use: You can proof this with ##{{{ssh server wget -O - https://127.0.0.1:8080/}}}## which should display the error message //Connection refused//. If not, something is running there and it should be stopped.
260 * You can then create the tunnel with the following ##ssh -R8080:127.0.0.1:8080 server##. This tells the server that incoming ("R"emote) connections on port 8080 on the server are to be tunnelled to the local (laptop) port 8080. This method has the advantage that the laptop (typically using a dynamic address) invokes the SSH where as a proxy configured on the server to proxy to the laptop would need to know the address of the laptop.
261
262 == Configuring tomcat for https ==
263
264 Although allowing users to directly connect to tomcat is not recommended, for a variety of reasons it may be desirable to configure tomcat to serve pages over an https connection.
265
266 * If using HTTPS for accessing XWiki, several modifications have to be made to ensure proper functionality. Since urls are generated from relative path (##/xwiki/bin/show/Space/Page##), Tomcat has to know which protocol to use, otherwise JSON requests with redirect fails (attachment uploads, extension updating, etc.)
267 * Modify connector (in ##server.xml##) to {{code}}<Connector port="8080" ... secure="true" scheme="https" />{{/code}}
268 * Modify host (in ##server.xml##) and add Remote Ip Valve {{code}}<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="x-forwarded-for" protocolHeader="x-forwarded-proto" />{{/code}} (only needed if using another server for HTTPS)
269
270 {{info}}
271 If using another server as a HTTPS proxy (such as Nginx or Apache httpd), ##X-Forwarded-For## and ##X-Forwarded-Proto## headers have to be set!
272 {{/info}}
273
274 = Troubleshooting =
275
276 == Out Of Memory Error ==
277
278 When you run XWiki in Tomcat with the default settings, you'll probably get an ##Out Of Memory## error (##java.lang.OutOfMemoryError: Java heap space## or ##java.lang.OutOfMemoryError: PermGen space##) since the default Tomcat memory settings are not enough for [[XWiki Memory Requirements>>platform:AdminGuide.Performances#HMemory]]. You'll need to allocate more memory to the JVM.
279
280 One easy solution to configure Tomcat's memory is to create a ##setenv.sh## file (or ##setenv.bat## on Windows) in ##[TOMCAT_HOME]/bin/## (where ##[TOMCAT_HOME]## is where you've installed Tomcat) and inside this file add the following (adjust the memory values according to the [[XWiki Memory Requirements>>platform:AdminGuide.Performances#HMemory]]). For example:
281
282 {{code language="none"}}
283 CATALINA_OPTS="-Xmx1024m -XX:MaxPermSize=192m"
284 {{/code}}
285
286 On most Linux distributions, this can also be achieved in ##/etc/tomcat//X///tomcat//X//.conf## or ##/etc/conf.d/tomcat//X//.conf## (where //X// is the version of Tomcat installed).
287
288 On Windows, if you are running Tomcat as a service then defining ##CATALINA_OPTS## will not help. There is an utility provided in the ##bin## folder of your Tomcat installation (for example for Tomcat 5.x on Windows it's called tomcat5w.exe). It's a GUI tool which can be used to set various options including the heap size.
289
290 == Java Security Manager ==
291
292 By default Tomcat is configured to have the Java Security Manager turned on. See the [[sample policy file>>platform:AdminGuide.InstallationWAR#HInstallandconfigureaServletContainer]] for more details.
293
294 If you want to turn off the Java Security Manager for Tomcat, edit the Tomcat startup script. You might also want to check your ##/etc/init.d/tomcat## file or ##/etc/default/tomcat5.5##. You should see the following code:
295
296 {{code}}
297 # Use the Java security manager? (yes/no)
298 TOMCAT5_SECURITY=
299 {{/code}}
300
301 Set it to ##no## to turn off the Security Manager.
302
303 == Allowing "/" and "\" in page names ==
304
305 Tomcat completely freaks out when there's a ##%2F## or ##%5C## in URLs and it's not something that can be changed in XWiki. See [[this note>>http://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10]] for more information.
306
307 You can configure Tomcat to allow "/", by setting the ##org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH## system property to ##true##, as in:
308
309 {{code}}
310 -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
311 {{/code}}
312
313 And by setting the ##org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH## system property to ##true## to allow "\", as in:
314
315 {{code}}
316 -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true
317 {{/code}}
318
319 To have both properties permanently enabled on your Tomcat instance, add the lines below to your ##CATALINA_OPTS## environment variable. How to achieve this depends on your operating system, Tomcat distribution and single/multi-instance setup.
320
321 {{code}}
322 -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
323 -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true
324 {{/code}}
325
326 Note that if you're using the Apache web server, you also need to [[configure Apache to allow encoded / and \>>https://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes]].
327
328 == NotSerializableException ==
329
330 If you get the following:
331
332 {{code}}
333 SEVERE: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.xwiki.model.internal.reference.LocalStringEntityReferenceSerializer
334 java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.xwiki.model.internal.reference.LocalStringEntityReferenceSerializer
335 at java.io.ObjectInputStream.readObject0(Unknown Source)
336 at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
337 {{/code}}
338
339 This means that on startup Tomcat tries to load saved Sessions and fails to do so. In this case it fails because some non-serializable object was put in the Servlet Session. To work around the issue [[you can tell Tomcat to not save sessions>>http://dev-answers.blogspot.fr/2007/03/how-to-turn-off-tomcat-session.html]].
340
341 == SEVERE: Error listenerStart ==
342
343 If you get this error in your Tomcat logs then you'll need to enable finer-grained logging configuration to see what's the problem. For Tomcat 6.x/7.x this involves copying the following content in a ##WEB-INF/classes/logging.properties## file:
344
345 {{code}}
346 org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
347 org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
348 {{/code}}
349
350 == Parameter count exceeded allowed maximum ==
351
352 If you get an error such as the following it means you reached the limit of parameters you can send in a form.
353
354 {{code}}
355 java.lang.IllegalStateException: Parameter count exceeded allowed maximum: 512
356 {{/code}}
357
358 You can set the value you want by setting the following in your Tomcat ##server.xml## file:
359
360 {{code}}
361 <Connector port=... maxParameterCount="10000" />
362 {{/code}}

Get Connected