nabeel shahzad

Archive for the ‘ruby’ tag

Installing Redmine on Ubuntu 11.04 w/nginx and mongrel

without comments

This one took me a few hours, but I’ve got my handy-dandy notes. I’m going to assume you’re got nginx installed, whether there are vhosts or not…

I’m also installing to /var/www/redmine

Java
1
2
3
4
5
6
7
sudo apt-get install mongrel ruby gems
cd /var/www
wget http://rubyforge.org/frs/download.php/75097/redmine-1.2.1.tar.gz
tar xzvf redmine-1.2.1.tar.gz
mv redmine-1.2.1 redmine
sudo chown www-data: redmine -R
sudo chmod 775 redmine -R

Next, we are going to patch Redmine, to work with Mongrel

Java
1
2
3
4
5
cd /var/www/redmine/config/initializers/
wget http://www.redmine.org/attachments/6146/rails_6440_patch.rb
wget https://gist.github.com/raw/826692/cb0dcf784c30e6a6d00c631f350de99ab99e389d/mongrel.rb
sudo chmod 775 . -R
sudo chown www-data: -R

Next, setup the right versions of Rails, etc

Java
1
2
3
gem install -v=2.3.14 rails
gem install rack -v=1.1.1
gem install rake -v0.8.7

Now setup MySQL:

Java
1
2
3
4
mysql -uroot -p
create user 'redmine'@'localhost' identified by 'password';
grant all privileges on `redmine%` . * to 'redmine'@'localhost';
create database redmine character set utf8;

And next, we configure and run the installer for Redmine. We are going to edit the database.yml, set it to match your above settings

Java
1
2
3
4
5
6
7
cd /var/www/redmine/config
mv database.yml.production database.yml
nano database.yml
cd /var/www/redmine
rake generate_session_store
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

Next, we start the server

Java
1
mongrel_rails start -e production -p 9001 -d

Next, create the nginx vhost, I created it as /etc/nginx/sites-enabled/redmine

Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
server {
listen 80;
server_name YOUR_HOSTNAME_HERE;
root /var/www/redmine/public;
#error_log /var/log/nginx/redmine.log debug;
expires epoch;
location / {
expires epoch;
alias /var/www/redmine/public/;
try_files $uri/index.html $uri.html $uri @mongrel;
}
location @mongrel {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass_header Set-Cookie;
proxy_pass http://127.0.0.1:9001;
}
}

Written by Nabeel

October 3rd, 2011 at 6:11 pm

Posted in General,nginx

Tagged with ,