#Yesterday I tried and succesfully managed to install Redmine on an Arch Linux server. I found it difficult to install Redmine on Arch because the instructions of Redmine and the wiki page on the Arch Linux wiki wheren’t clear, or at least I struggled with following those instructions. That is why I have written this tutorial.
In this tutorial we will install Redmine, but also MariaDB as a database server (required by Redmine) and Apache as the webserver.
I assume you have Arch up and running and for the convenience I also assume you have installed Yaourt
Install Apache with the following command:
$ sudo pacman -S apache
We have to load the right MPM module for apache because the Passenger module requires this (which we will install later on).
Open /etc/httpd/conf/httpd.conf and scroll down and make the following changes
LoadModule mpm_event_module modules/mod_mpm_event.so To #LoadModule mpm_event_module modules/mod_mpm_event.so and #LoadModule mpm_prefork_module modules/mod_mpm_prefork.so To LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
Enable and start the apache service
$ sudo systemctl enable httpd.service $ sudo systemctl start httpd.service
MariaDB is a fork of MySQL and compatible with MySQL.
Install MariaDB with the following command
$ sudo pacman -S mariadb
Configuration of MariaDB
We have to setup a data directory, enable and start the MariaDB service.
$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql $ sudo systemctl enable mysqld.service $ sudo sytemctl start mysqld.service
We also have to secure our installation, creating a root user and a root password etc. Use the following command. The tool will ask for a root password, and will ask if the test database should be removed etc.. Just specify as you like.
$ sudo mysql_secure_installation
The Redmine Arch Wiki recommends to use RVM as Ruby. With RVM you can deploy muliple ruby environments in one system.
To install RVM you need git and curl. And you need to decide wether you want a single user environment or a multi user environment. I have choosen to use the single user environment because my server has only one purpose and that is redmine.
$ sudo pacman -S git curl
Install RVM into your user account. Assume you are logged in as a normal user (my user name is jaap, so I am logged in as jaap)
$ cd /home/jaap $ curl -L get.rvm.io | bash -s stable $ bash < ./rvm-install
Edit .bashrc and add to the end the following lines
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" export PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
After that reload your .bashrc file.
$ source ~/.bashrc
Check if everything is working with the following commands:
$ type rvm | head -n1 $ rvm notes $ rvm requirements
Then install the right Ruby version. In my case it was 1.9.3
$ rvm install 1.9.3
Install Ruby packages (gems)
$ gem install bundler prototype-rails unicorn mysql2 coderay erubis fastercsv rdoc net-ldap rack-openid
If the command gem is not found on your system you have to install ruby.
$ sudo pacman -S ruby #only if gem doesn't exist on your system
Install Redmine from AUR
Install Redmine with Yaourt from AUR. I assume you know a little bit about the Arch Linux Packaging system.
$ Yaourt -S redmine
Create a redmine database and database user
In this step we will create the database for Redmine and a redmine database user. Please remember the password you set for this user we will need this later on.
$ mysql -u root -p CREATE DATABASE redmine CHARACTER SET UTF8; CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password'; GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
Configure Redmine to use this database. Copy the database config file and change it.
$ cd /usr/share/webapps/redmine/config $ sudo cp database.yml.example database.yml $ sudo nana database.yml
production: adapter: mysql2 database: redmine host: localhost username: redmine password: my_password
Install Redmine dependencies
Install all the gem packages with bundler for Redmine. If you don’t understand the previous sentence. It means please execute the command below. This command will try to install Ruby packages which are required by Redmine.
$ cd /usr/share/webapps/redmine $ bundle install --without development test rmagick
Finalize the setup
In this step we will create a session token and create the database.
$ cd /usr/share/webapps/redmine $ rake generate_secret_token $ RAILS_ENV=production rake db:migrate $ RAILS_ENV=production rake redmine:load_default_data # set the right file permissions $ sudo mkdir tmp tmp/pdf public/plugin_assets $ sudo chown -R http:http /usr/share/webapps/redmine $ sudo chmod -R 755 files log tmp tmp/pdf public/plugin_assets
Test if Redmine works
You could test now if Redmine works.
$ ruby bin/rails server webrick -e production
If the command launches succesful you could access redmine on http://localhost:3000
In the next step we will launch Redmine from within Apache. So that a user could go http://redmine.yourdomain.com
Install Passenger (for starting Redmine from within Apache)
Passenger is a module for Apache to start other application from within Apache. So that those applications will serve the webpages.
$ cd ~ $ gem install passenger $ passenger-install-apache2-module
Find your rube environment
$ passenger-config about ruby-command passenger-config was invoked through the following Ruby interpreter: Command: /home/jaap/.rvm/gems/ruby-1.9.3-p551/wrappers/ruby Version: ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux] To use in Apache: PassengerRuby /home/jaap/.rvm/gems/ruby-1.9.3-p551/wrappers/ruby To use in Nginx : passenger_ruby /home/jaap/.rvm/gems/ruby-1.9.3-p551/wrappers/ruby To use with Standalone: /home/jaap/.rvm/gems/ruby-1.9.3-p551/wrappers/ruby /home/jaap/.rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.15/bin/passenger start ## Notes for RVM users Do you want to know which command to use for a different Ruby interpreter? 'rvm use' that Ruby interpreter, then re-run 'passenger-config about ruby-command'.
Note the line with ‘To use in Apache:’
Now create a virtual host file for Apache for the domain redmine.yourdomain.com
$ sudo nano /etc/httpd/conf/redmine.yourdomain.com <VirtualHost *:80> ServerName redmine.yourdomain.com # Tell Apache and Passenger where your app's 'public' directory is DocumentRoot /usr/share/webapps/redmine/public #Tell apache which ruby to use. We have found the location by the command passenger-config earlier PassengerRuby /home/jaap/.rvm/gems/ruby-1.9.3-p551/wrappers/ruby # Relax Apache security settings <Directory /usr/share/webapps/redmine/public> SetEnv RAILS_ENV production SetEnv RailsEnv production Allow from all Options -MultiViews # Uncomment this if you're on Apache > 2.4: Require all granted </Directory> </VirtualHost>
Now we have to include our virtualhost configuration in the httpd.conf. At at the end of /etc/httpd/conf/httpd.conf the following line
Now restart Apache
$ sudo systemctl stop httpd.service $ sudo systemctl start httpd.service
When you go to http://redmine.yourdomain.com you should see Redmine.
Default user name and password.
The default username is admin and the default password for admin is admin.
Configure SMTP for sending e-mails
The last step I had to complete was to configure Redmine to use my smtp server for sending e-mails.
$ cd /usr/share/webapps/redmine/conf $ sudo cp configuration.yml.example configuration.yml
Change the lines according to your smtp settings. Mine was as follows:
... default: # Outgoing emails configuration # See the examples below and the Rails guide for more configuration options: # http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration #email_delivery: # ==== Simple SMTP server at localhost # # email_delivery: # delivery_method: :smtp # smtp_settings: # address: "localhost" # port: 25 # # ==== SMTP server at example.com using LOGIN authentication and checking HELO for foo.com # email_delivery: delivery_method: :smtp smtp_settings: address: "smtp.yourdomain.com" port: 587 authentication: :login domain: 'yourdomain.com' user_name: 'firstname.lastname@example.org' password: 'jhjidk7kjITRT' enable_starttls_auto: false ... ... ...
Notice: spacing in this file comes very accurate. Do not use tabs for indenting but use two spaces.
After you have entered your smtp details. Restart apache.
$ sudo systemctl stop httpd.service $ sudo systemctl start httpd.service