In this tutorial, we will explain how to install Redmine 2.6 on an Ubuntu 14.04 VPS with MariaDB, Puma and Nginx. Redmine is a flexible open source issue tracking and web-based project management application . Redmine is built on Ruby on Rails framework and it is cross-platform and cross-database. This guide should work on other Linux VPS systems as well but was tested and written for Ubuntu 14.04 VPS.
Login to your VPS via SSH
ssh user@myVPS
Update the system and install necessary packages
user@myVPS:~# sudo apt-get update && sudo apt-get -y upgrade user@myVPS:~# sudo apt-get install python-software-properties \ curl autoconf subversion bison software-properties-common \ imagemagick libmagickwand-dev build-essential libssl-dev \ libreadline-dev libyaml-dev zlib1g-dev git openssl vim
Install MariaDB 10.0
user@myVPS:~# sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db user@myVPS:~# sudo add-apt-repository 'deb http://mirror.pw/mariadb/repo/10.0/ubuntu trusty main' user@myVPS:~# sudo apt-get install mariadb-server libmariadbclient-dev
When the installation is complete, run the following command to secure your installation:
mysql_secure_installation
Next, we need to create a database for our Redmine installation:
mysql -uroot -p MariaDB [(none)]> CREATE DATABASE redmine CHARACTER SET utf8; MariaDB [(none)]> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'redmine_passwd'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
Redmine user
Create a new system user for Redmine.
user@myVPS:~# sudo adduser --home /opt/redmine --shell /bin/bash --gecos 'Redmine application' redmine user@myVPS:~# sudo install -d -m 755 -o redmine -g redmine /opt/redmine user@myVPS:~# sudo usermod -a -G sudo redmine user@myVPS:~# sudo su - redmine
Install Ruby using RVM
redmine@myVPS:~# cd redmine@myVPS:~# curl -sSL https://rvm.io/mpapis.asc | gpg --import - redmine@myVPS:~# curl -sSL https://get.rvm.io | bash -s stable --ruby
To start using RVM run
redmine@myVPS:~# source ~/.rvm/scripts/rvm
To verify everything is done correctly, use the command ruby --version
.
The output should be similar to the following:
redmine@myVPS:~# ruby --version ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
Install Redmine
The following commands will checkout the Redmine source code to the ~/redmine
directory and create some directories.
redmine@myVPS:~# cd && svn co http://svn.redmine.org/redmine/branches/2.6-stable redmine
redmine@myVPS:~# mkdir -p ./redmine/tmp/pids ./redmine/public/plugin_assets
Configure database settings
redmine@myVPS:~# cp ./redmine/config/configuration.yml.example ./redmine/config/configuration.yml redmine@myVPS:~# cp ./redmine/config/database.yml.example ./redmine/config/database.yml
Open the database.yml
file and update username/password
redmine@myVPS:~# vim ./redmine/config/database.yml
production: adapter: mysql2 database: redmine host: localhost username: redmine password: "redmine_passwd" encoding: utf8
Create a new Puma configuration file.
redmine@myVPS:~# vim ./redmine/config/puma.rb
#!/usr/bin/env puma application_path = '/opt/redmine/redmine' directory application_path environment 'production' daemonize true pidfile "#{application_path}/tmp/pids/puma.pid" state_path "#{application_path}/tmp/pids/puma.state" stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" bind "unix://#{application_path}/tmp/sockets/redmine.sock"
Install Gems
redmine@myVPS:~# cd /opt/redmine/redmine redmine@myVPS:~# echo "gem 'puma'" >> Gemfile.local redmine@myVPS:~# echo "gem: --no-ri --no-rdoc" >> ~/.gemrc redmine@myVPS:~# bundle install --without development test postgresql sqlite
Prepare the database
redmine@myVPS:~# rake generate_secret_token redmine@myVPS:~# RAILS_ENV=production rake db:migrate redmine@myVPS:~# RAILS_ENV=production REDMINE_LANG=en rake redmine:load_default_data
Create an Upstart script
redmine@myVPS:~# sudo vim /etc/init/redmine.conf
description "Puma Redmine Service" start on filesystem or runlevel [2345] stop on runlevel [!2345] setuid redmine setgid redmine respawn script exec /bin/bash << EOT source /opt/redmine/.rvm/scripts/rvm cd /opt/redmine/redmine bundle exec puma --config config/puma.rb EOT end script
You can now start your Redmine service with :
redmine@myVPS:~# sudo service redmine start
Install and configure Nginx
Installing Nginx is pretty easy, just run the following command:
redmine@myVPS:~# sudo apt-get install nginx
Next, create a new Nginx server block:
redmine@myVPS:~# sudo vim /etc/nginx/sites-available/redmine.domain.com
upstream redmine { server unix:/opt/redmine/redmine/tmp/sockets/redmine.sock; } server { server_name redmine.domain.com; root /opt/redmine/redmine; location / { try_files $uri @ruby; } location @ruby { 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_redirect off; proxy_read_timeout 300; proxy_pass http://redmine; } }
Activate the server block by creating a symbolic link and restart Nginx:
user@myVPS:~# sudo ln -s /etc/nginx/sites-available/redmine.domain.com /etc/nginx/sites-enabled/redmine.domain.com user@myVPS:~# sudo service nginx restart
That’s it. You have successfully installed Redmine on your Ubuntu VPS. For more information about Redmine, please refer to the Redmine website.
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
Hi, your guide was very helpful to me. Tanks for that.
I have one question. How can redmine can be restarted with this installation method. Out-there is a lot of documentation about restart redmine installed over Apache or over nginx-passenger, but in this case the installation is through puma, so there’s not much information about this. I installed some plugins and changed configuration so I need to restart redmine. Could you tell me how to do this please?
Use the following command:
sudo service redmine restart
Hi,
I followed your steps with one spin, used redmine 3.1.
I get 100% cpu usage on vps
any ideas why?
ok… it was puma, needed to update to newest version..got down from 100% cpu to 25% cpu
still wondering why
You may use top, mpstat and other tools to find out more about your server CPU usage.
Please check this htop screenshot
http://s23.postimg.org/plgc10km3/redmine_issue.gif
I have the same problem as Kamil (also on 3.1). Ruby locks up an entire core. Any ideas?
Please try to update Puma to the latest version available and see if it will fix the problem.
server unix:/opt/redmine/redmine/tmp/sockets/redmine.sock;
How do you create a socket? What should it look like? You don’t mention it. I can’t run nginx without it.
connect() to unix:~/redmine/redmine/tmp/sockets/redmine.sock failed (2: No such file or directory)
I got it now.
I just didn’t use the puma script as I installed it before.
I really can’t understand why we use sockets and how they function. So if it’s not too difficult, could you explain it to me in a few words?
Thanks. Great post.
Unix socket is a data communications endpoint for exchanging data between processes executing on the same host operating system.
Thanks.
How can I start redmine? when i ‘sudo service start redmine’,it print “Failed to start redmine.service: Unit redmine.service not found”!
Most likely you haven’t created the Redmine Upstart script. To start the Redmine service you need to create the Upstart script first.
Thanks.