Pardon the dreariness of this post. I did this twice in a couple of days. I thought I might as well write down what I did, to save me time next time. Let me state first that this is an opinionated install :-) I don’t like bloated Tomcat installations with many applications on them. I prefer to have each application in its own place with its own server. So I will use the Confluence standalone package, which is integrated with Tomcat. When I will install Jira on the same box, I will download another standalone package.
Preparations
Connect to your server. Execute
apt-get install apache2 ca-certificates
apt-get install mysql-server
Create file /etc/mysql/conf.d/confluence.cnf with the following contents
[mysqld]
default-storage-engine=innodb
lower_case_table_names=1
Then restart mysql with
/etc/init.d/mysql restart
Edit /etc/apt/sources.list, appending the string ” non-free” to every line.
Then execute
apt-get install sun-java6-jdk
Install Confluence
Download the Confluence standalone package for gnu/linux (not the one for
evaluation)
wget http://www.atlassian.com/software/confluence/downloads/binary/confluence-3.0.2-std.tar.gz
Create the directory /opt/confluence. In that directory, expand the confluence
archive. Then create a symlink from /opt/confluence/confluence-app to the
actual directory that contains the confluence application
ln -s /opt/confluence/confluence-3.0.2-std /opt/confluence/confluence-app
Then create directory /opt/confluence/confluence-data.
Edit the file confluence/WEB-INF/classes/confluence-init.properties within the
confluence distribution, and add the line
confluence.home=/opt/confluence/confluence-data
Edit the file conf/server.xml and change the following:
- Change 8080 and 8000 to something other than these, which are the default
Tomcat ports and might be useful some other day. I use 8180 and 8100.
- In the first Connector element, add the attribute address=”127.0.0.1″. This
will make Tomcat bind to localhost only. I don’t want to make Tomcat
directly accessible from the outside.
- In the first Context element, change path=”” to path=”/confluence”.
Otherwise I can’t get the reverse proxy from Apache to work.
Create a file /opt/confluence/startup-confluence.sh with the following contents:
export JAVA_HOME=/usr/lib/jvm/java-6-sun
su -m www-data -c /opt/confluence/confluence-app/bin/startup.sh
Change ownership of the whole /opt/confluence thing to www-data
chown -R www-data.www-data /opt/confluence
chmod +x /opt/confluence/startup-confluence.sh
Download the mysql driver
wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.10.tar.gz/from/http://mirror.switch.ch/ftp/mirror/mysql/
Extract the archive, and copy the jar it contains to
/opt/confluence/confluence-app/lib
Create the database and the user for confluence
# mysql -uroot -p
mysql> create database confluence;
mysql> grant all on confluence.* to confluence@127.0.0.1 identified by 'secret';
Now if you didn’t do this when first connecting, exit from ssh and reconnect to create a tunnel, to be able to browse Confluence from localhost on the server.
ssh -L1234:localhost:8180 root@myserver
Execute /opt/confluence/startup-confluence.sh, then point the browser to
http://localhost:1234/confluence
You should see the confluence configuration screen. Now just follow the wizard. Remember to choose “Custom installation”, “External database”, and “Mysql”.
When Confluence is up and running, we still have some things to do. Let’s configure Apache to serve Confluence in http://myserver/confluence . Edit /etc/apache2/site-available/default and add the following lines:
<Location /confluence>
Order allow,deny
Allow from all
ProxyPass /confluence http://127.0.0.1:8180/confluence
ProxyPassReverse /confluence http://127.0.0.1:8180/confluence
Then execute
a2enmod proxy proxy_http
/etc/init.d/apache2 reload
You should now be able to see Confluence at http://myserver/confluence
Now we must make sure that Confluence will start at system boot. Just call
/opt/confluence/startup-confluence.sh in /etc/rc.local. It’s simple, and it
works.
You may stop here unless you want to serve Confluence via ssl. In that case… let’s carry on. Execute
a2ensite default-ssl
a2enmod ssl
/etc/init.d/apache2 reload
You should be able to access https://myserver/ now. Now move the proxypass configuration from sites-available/default to sites-available/default-ssl.