Posts Tagged ‘galaxy’

Installing Galaxy on CentOS 6.3 with an mysql db and running it as a non-root user

Friday, February 8th, 2013

There’s a biomedical reaseach software called Galaxy. I didn’t know that either 😉
The installation is easy but it uses a sqlite ‘db’ and must be started by whoever wants to use it. In a production environment, this is not convenient and does not scale nicely. To be fair, the makers provide infos on how to run it in a production environment.

Here is one such installation in details. maybe this helps you.
-OS: CentOS 6.3
-DB: mysql
-Galaxy is run by a non-root user
-Galaxy starts at system boot

Lines starting with # must be run as root, some lines are comments so you can’t just paste line by line in your shell. Make sure you understand what you do (the line breaks make it a bit hard to read though, sorry)

After the installation, open firefox. To use galaxy, visit localhost:8080


= Installation of Galaxy with a local mysql DB on CentOS6 =


# yum install mysql-server
# yum install mysql
# yum install mysql-devel

# service mysqld start

# /usr/bin/mysql_secure_installation

Set root password? [Y/n] Y
root pwd: <pwd>

Remove anonymous users? [Y/n] Y

Disallow root login remotely? [Y/n] Y

Remove test database and access to it? [Y/n] Y

Reload privilege tables now? [Y/n] Y


(sets mysqld to start on reboot)
# chkconfig mysqld on

add another db user

/usr/bin/mysql -u root -p (enter pwd)

mysql> INSERT INTO mysql.user (User,Host,Password) VALUES(‘galaxy’,’localhost’,PASSWORD(‘<pwd>’));

create a galaxy db

mysql> CREATE DATABASE galadb;

grant user ‘galaxy’ all permissions on db ‘galadb’

mysql> GRANT ALL PRIVILEGES ON galadb.* to galaxy@localhost;
mysql> quit


# yum install mercurial

galaxy installation

# cd /usr/local
# mkdir galaxy
# cd galaxy/
# hg clone

# sh galaxy-dist/

–> starts a local galaxy instance, can be opened in a browser with localhost:8080
^C –> quits

change settings for production server


disable developer settings

cd /usr/local/galaxy/galaxy-dist/
# cp universe_wsgi.ini universe_wsgi.ini.orig
# vim /usr/local/galaxy/galaxy-dist/universe_wsgi.ini
(line 370) debug = True –> debug = False
(line 383) use_interactive = True –>  use_interactive = False

use a local mysql db

set db connection in universe_wsgi.ini
(line 93) database_connection = mysql://galaxy:<pwd>@localhost/galadb?unix_socket=/var/lib/mysql/mysql.sock

securing the galaxy installation by running it as non-root

(create a local user “galaxy”)
# useradd -c “local user for galaxy installation” -d /home/galaxy -m -U galaxy
# passwd galaxy <pwd>

* running galaxy with the local user galaxy will throw an error
ssh galaxy@host
[galaxy@host ~]$ sh /usr/local/galaxy/galaxy-dist/
OSError: [Errno 13] Permission denied: ‘./database/tmp/tmpeeJTbo’
* so we need to fix this by chowning the installation folder to galaxy

# cd /usr/local/galaxy/
# chown -R galaxy:galaxy galaxy-dist/

* now it should run
ssh galaxy@host
[galaxy@host ~]$ sh /usr/local/galaxy/galaxy-dist/
Starting server in PID <PID>.
serving on
* yes, it does

crontab fuer user galaxy:
@reboot $SHELL /usr/local/galaxy/galaxy-dist/ >>/tmp/galaxy.log
* –> galaxy will run after the next reboot
* as the log file is in /tmp, it delete disappear after a reboot
* put it into /var/log and chown it to make it more persistent
* after reboot, you can check if galaxy was really run at system boot: * [user@host ~]$ ps -ef | grep gala
* galaxy    2864  2862  0 15:44 ?        00:00:00 /bin/sh -c $SHELL /usr/local/galaxy/galaxy-dist/ >>/tmp/galaxy.log
* galaxy    2865  2864  0 15:44 ?        00:00:00 /bin/sh /usr/local/galaxy/galaxy-dist/
* galaxy    3148  2865  2 15:44 ?        00:00:07 python ./scripts/ serve universe_wsgi.ini
* galaxy    3180  2862  0 15:44 ?        00:00:00 /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root