Joined: 14 Dec 2004
|Posted: Sun May 25, 2008 10:17 pm Post subject: Installing Cyclos on port 80 ->tomcat/ apache/ mod_proxy_
|This was my experience installing Cyclos -a complementary currency system- on Gentoo using mod_proxy_ajp to make it accessible on port 80.
Official Cyclos installation document can be found at:
software versions used:
First thing I had to do on my box was upgrade apache from 2.0 to 2.2 so that I could use mod_proxy_ajp.
If you need to do this too, take your time to read the docs at Gentoo and apache.org.
There are many differences between both versions so you will need to modify many config files by hand in order to get it working. Double check that you are building apache with all the necessary modules.I
If you are lucky and you already have 2.2 running, next thing is:
As you will see in the post-install notes, Gentoo installation of Tomcat is somewhat heterodox as it tries to comply with the FHS layout and thus does not install everything under /opt as is usual with this package on other distros.
You should read the Tomcat Gentoo guide at this point.
In my particular case I needed tomcat to run on a different port than 8080 because I'm already using that one for Zope. If this is your case, you'll need to edit the /etc/tomcat-6/server.xml file and replace any occurrences of 8080 for 8090 or whatever port number you choose.
With your tomcat install in place it's now time to download cyclos itself.
It's available at the sourceforge download page for the project. The most current version at the moment of this writing is 3.0.8. You should get the cyclos_VERSION.zip file, not the standalone if you are planning to run it with this tomcat/apache setup.
In Gentoo, tomcat webapps are installed under the /var/lib/tomcat-6/webapps/ directory, so you should unzip the file you downloaded to some temporary folder and copy the extracted web/ directory to your /var/lib/tomcat-6/webapps folder. Rename web/ to whatever you please, I just named it cyclos. Remember also to set the ownership of this folder and it's content to tomcat:
|# chown tomcat:tomcat /var/lib/tomcat-6/webapps/cyclos -R
Next thing you'll need to do is edit the WEB-INF/classes/cyclos.properties file.
It's important here that you change the 8080 port to whatever port you've configured tomcat to run at.
In my case:
You also need to set the url (which depends on what you renamed the web/ directory to).
In my case the line reads:
And the database data needs to be set to whatever your configuration will be.
I'm using mysql, so under the ###MySQL section I had to change these lines:
|hibernate.connection.url = jdbc:mysql://localhost/cyclos
hibernate.connection.username = cyclos
hibernate.connection.password = your_password_here
In this version of cyclos the database name came for some reason set to puntotransacciones, which as you can see I've changed to cyclos.
Done with the editing.
If you haven't set up your MySQL database yet, now is the time.
Create a database called cyclos (or whatever you've used in the properties file) and grant all privileges on it to cyclos@localhost user like so:
|mysql> create database cyclos;
mysql> grant all privileges on cyclos.* to cyclos@localhost identified by 'your_password_here';
mysql> flush privileges;
mysql> Ctrl-D to exit
Everything is in place. You should now start or restart your tomcat service:
|# /etc/init.d/tomcat start |
Don't forget to add the service to your default runlevel so it gets started when the server reboots.
|# rc-update add tomcat-6 default |
You are all set now to try cyclos on port 8090 (or whatever port you have chosen).
Point your browser at http://localhost:8090/cyclos or at your server's public IP:8090/cyclos
If you don't get the cyclos login page something has gone wrong.
You should check your log files at:
First thing to check is that tomcat is effectively running on port 8090.
Point your browser at http://localhost:8090/ to check this.
If tomcat is running you can use the manager tool to start and stop webapps.
The manager tool is available under Administration in the left hand panel of the standard tomcat welcome page. In order to be able to login you'll need to edit /etc/tomcat-6/tomcat-users.xml and add a user so you can log-in.
My file looks like this after editing:
|<?xml version='1.0' encoding='utf-8'?>
<user username="your_username" password="your_password" roles="standard,manager"/>
I restarted tomcat after editing the file, but don't know if it's necessary.
Once you log in to the Tomcat Manager you'll see your cyclos webapp listed and it's current status.
I find it helpfull to run on a ssh terminal:
|# tail -f /var/log/tomcat-6/localhost.2008-05-25.log |
while on the manager interface I try to start the cyclos webapp.
This will show in real time what's going wrong with the setup.
In my case the problem was that I had left the database name line unchanged in the cyclos.properties file and so my log showed that the cyclos user was unable to open the puntotransacciones database
Of course YMMV here.
Once everything is working well on port 8090 all you need to do is add some lines to your VirtualHost on apache to have it redirect requests to tomcat using mod_proxy_ajp.
You can read about it in this howto.
All I had to do is edit /etc/apache2/vhosts.d/www.myvirtdomain.org.conf (you should change this to the domain you'll be using) and add the following lines inside de VirtualHost section:
You should check that you are loading the proxy module for apache.
In your /etc/conf.d/apache2 file you should add -D PROXY to the APACHE2_OPTS values.
Restart apache and that's it.
The cyclos instance is now available at http://www.myvirtdomain.org.ar/cyclos
If you are planning to run more than one instance of cyclos on the same server you'll need to make as many copies of the original web/ folder you extracted from cyclos_VERISON.zip
under your webapps directory. You'll have to adjust the cyclos.properties file in each instance to reflect the URL/folder and the database configuration data. You should create as many databases as cyclos instances you'll be using.
And last but not least, you will need to tune the amount of RAM that is assigned to tomcat by modifying the file /etc/conf.d/tomcat-6 and adding the line:
Or whatever amount of RAM you need. I'm running three instances and 96Mb seems to be the minimum amount to have the three of them started.
Once again the Tomcat Manager is your friend if you need to see what instances have been started and which haven't.
Read the logs to find out what's happening. If the amount of RAM is too small you'll see a message saying something like:
|Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: Java heap space |
Increase the amount of memory by changing the -Xmx value, restart tomcat and try again.
You may also add the corresponding directives to your vhost in apache.
In my case I have:
Doing this will give a warning on apache start and stop because we are using the same context and JVM on port 8009 for the three instances.
I'm using this setup but still don't know if the warning is important or not. Time will say i guess!
If you wish to explore this subject you may find this document - section Configuring for Multiple Tomcat JVMs- enlightening.
If you find any mistakes in this simple guide just let me know so I can correct them.
Good luck and happy local trading