Installing Redmine on Centos 6 Dot 2 With Mysql and Apache
I needed recently to install the excellent project management tool Redmine on a CentOS 6.2 machine. There are some tutorials on the Web (here or here) but they are a little bit outdated. The following is a method that works as of today.
Pre-requisites
Logged as root, install the following packages:
yum install make gcc gcc-c++ zlib-devel ruby-devel rubygems ruby-libs apr-devel apr-util-devel httpd-devel mysql-devel mysql-server automake autoconf ImageMagick ImageMagick-devel curl-develAnd then install the bundle ruby gem:
gem install bundleInstall Redmine
Run the following commands to install Redmine:
cd /var/www
wget http://rubyforge.org/frs/download.php/76255/redmine-1.4.4.tar.gz
tar zxf redmine-1.4.4.tar.gz
ln -s redmine-1.4.4 redmine
rm -f redmine-1.4.4.tar.gzInstall Redmine ruby dependencies
Bundle helps us install the ruby Redmine dependencies:
cd /var/www/redmine
bundle install --without postgresql sqlite test developmentDatabase creation
First we start MySQL:
service mysqld startThen we secure it (Optional):
mysql_secure_installationWe then create the redmine database and user:
$ mysql
mysql> create database redmine character set utf8;
mysql> grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'my_password';
mysql> flush privileges;
mysql> quitRedmine database configuration
We copy the database configuration example and we modify it to point to our newly created database:
cd /var/www/redmine/config
copy database.yml.example database.ymlOn the database.yml file, the production section should look like this:
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: my_password
encoding: utf8And then we create and populate the database with the following rake commands:
cd /var/www/redmine
rake generate_session_store
rake db:migrate RAILS_ENV="production"
rake redmine:load_default_data RAILS_ENV="production"Outgoing email configuration (Optional)
To configure an outgoing SMTP server for sending emails, we create the
config/configuration.yml file from the sample:
cd /var/www/redmine/config
cp configuration.yml.example configuration.ymlAnd edit it to provide our configuration :
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: 'smtp.mydomain.com'
port: 25
domain: 'mydomain.com'Redmine standalone testing
At this point, Redmine can be tested in standalone mode by running the following command:
cd /var/www/redmine/
ruby script/server webrick -e productionand open the http://localhost:3000 address in a browser. If you are testing
from another computer, you will need to open the port in the
/etc/sysconfig/iptables file by duplicating the ssh (port 22) line and
adapting it:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPTThen apply the new configuration with the following command:
service iptables restartPassenger installation
To install Phusion passenger, we first install its gem:
gem install passengerAnd then install the Apache module with the command:
passenger-install-apache2-moduleApache configuration
We remove the default Apache configuration and replace it by a new one:
cd /etc/httpd
mv conf.d available
mkdir conf.dIn the empty new conf.d folder, we create a redmine.conf file with the
following configuration:
# Loading Passenger
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13
PassengerRuby /usr/bin/ruby
<VirtualHost *:80>
ServerName redmine.mycompany.com
DocumentRoot /var/www/redmine/public
<Directory /var/www/redmine/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
allow from all
</Directory>
ErrorLog "|/usr/sbin/rotatelogs /etc/httpd/logs/redmine-error.%Y-%m-%d.log 86400"
CustomLog "|/usr/sbin/rotatelogs /etc/httpd/logs/redmine-access.%Y-%m-%d.log 86400" "%h %l %u %t %D \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
</VirtualHost>We then enable named based virtual hosting for our server by uncommenting
the following line in the /etc/httpd/conf/httpd.conf file:
...
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
...We give full access on the redmine folder to the apache user and test the
configuration:
chown -R apache:root /var/www/redmine
service httpd configtestAt this point, the SELinux configuration needs to be modified to allow our apache instance to run the phusion passenger module. You can do this by putting SELinux in permissive mode:
setenfore PermissiveAnd letting the Permissive mode survive a reboot by modifying the
/etc/selinux/config file from:
SELINUX=enforcingto
SELINUX=permissiveIf you want to run redmine while enforcing, you may want to apply the method
described here for which you will need
to install the policycoreutils-python package.
In any case, you will start Apache with the command:
service httpd startNow you can access your Redmine installation with your browser. To access it
from all the computers in your network, you will need to open the port 80 in the
/etc/sysconfig/iptables. You can replace the 3000 rule by :
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPTAnd restart iptables.
service iptables restartStart services at boot
To have MySQL and Apache started at boot, run the commands:
chkconfig --level 345 mysqld on
chkconfig --level 345 httpd onCleaning up
A quick command to clean up all the devel stuff needed for installation:
yum remove '*-devel' make automake autoconfTips
Don’t forget that if you change your Redmine configuration, you don’t have to restart Apache. Your can restart only Redmine with the command:
touch /var/www/redmine/tmp/restart.txtIf you restore data on your server from another redmine instance that runs on a previous version, dont forget to migrate your data:
cd /var/www/redmine
rake db:migrate RAILS_ENV="production"