history 11 of 36
How to Install Redmine on CentOS 6 with Apache and Passenger
My notes from installing Redmine 1.4 on CentOS 6.3 with MySQL, Ruby gems, Passenger and an Apache virtual host, with corrected commands.
Written
- Web servers
- System administration
- Written for CentOS 6
- Written for Redmine 1.4
From my Linux study notes, 2014. Some commands and versions here are old, so please reuse them carefully. Anything marked "added later", and the notes at the end, explain what has changed since.
These are my notes from installing Redmine (a web-based project management and issue tracking tool) on CentOS 6.3.
Before you start
(Added later.)
- You need root access, or a user with
sudo. Run the commands below as root or with sudo. - Use a test server first. These steps change the Apache configuration.
- This guide is for an old setup: CentOS 6, Ruby 1.8 and Redmine 1.4.4. See “Notes for today” at the end before using it on a current system.
Install Redmine on CentOS 6.3
1. Install the required packages (as root)
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-develThis installs the compilers and development libraries needed to build Ruby gems, plus Apache development files (needed later for Passenger), the MySQL server, and ImageMagick.
2. Install Bundler
The original post said gem install bundle. The gem that provides the bundle command is called bundler, so the correct command is:
gem install bundler3. Install Redmine
mkdir /var/www/redminewget http://rubyforge.org/frs/download.php/76255/redmine-1.4.4.tar.gz(I am not sure if this method will work for newer versions.)
Added note: the original did not show unpacking the archive. Before the next step the Redmine files need to be extracted into /var/www/redmine, so that /var/www/redmine/config and /var/www/redmine/public exist. For example, from the directory where you downloaded the file:
tar -xzf redmine-1.4.4.tar.gzcp -r redmine-1.4.4/* /var/www/redmine/RubyForge has since shut down, so this download link no longer works. Get Redmine from the official site instead: https://www.redmine.org/
4. Install the Ruby dependencies
cd /var/www/redminebundle install --without postgresql sqlite test developmentThe original had - -without with a space; the option is --without (two hyphens, no space). It tells Bundler to skip the gem groups for PostgreSQL, SQLite, testing and development, because we are using MySQL in production.
5. Start MySQL
service mysqld start6. Secure MySQL
mysql_secure_installationThis interactive script lets you set the MySQL root password, remove anonymous users, disallow remote root login and remove the test database.
7. Create the database and user for Redmine
mysql -pcreate database redmine character set utf8;grant all privileges on redmine.* to 'redmine'@'localhost' identified by 'my_password';flush privileges;quitReplace my_password with a strong password of your own.
8. Configure the Redmine database connection
cd /var/www/redmine/configcp database.yml.example database.ymlIn database.yml, change the password for the production section to the password you set in step 7 (and check that the database name and username are redmine).
9. Create and populate the database with Rake
cd /var/www/redminerake generate_session_storerake db:migrate RAILS_ENV="production"rake redmine:load_default_data RAILS_ENV='production'The original had RAILS_ENV-"production" (a hyphen); it must be RAILS_ENV="production" with an equals sign.
generate_session_storecreates the secret used to sign session cookies (this is the Redmine 1.x task name).db:migratecreates the tables.redmine:load_default_dataloads the default roles, trackers and statuses. It asks you to choose a language.
10. Configure iptables and SELinux according to your needs
At minimum, port 80 must be open in the firewall for Apache. See the safety note in “Notes for today” about SELinux.
11. Install Passenger
gem install passenger12. Build the Passenger Apache module
passenger-install-apache2-moduleAt the end, this installer prints the exact LoadModule, PassengerRoot and PassengerRuby lines for your system. Use those lines in the next step, because the path depends on your Passenger and Ruby versions.
13. Apache configuration
cd /etc/httpdmv conf.d availablemkdir conf.dvi /etc/httpd/conf.d/redmine.confAdded note: mv conf.d available moves every existing file in /etc/httpd/conf.d out of use (on CentOS 6 this includes files such as welcome.conf and, if installed, php.conf and ssl.conf). That is fine on a server used only for Redmine, but on a shared server it will disable other sites and modules.
Paste the following into redmine.conf:
# Loading PassengerLoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13/ext/apache2/mod_passenger.soPassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.13# Please check your Passenger version and change it herePassengerRuby /usr/bin/ruby
<VirtualHost *:80> ServerName www.yourname.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>Changes from the original:
- A space was missing between
passenger_moduleand the path in theLoadModuleline. - In the original,
Options -MultiViewsandallow from allwere on the same line as the# MultiViews must be turned off.comment, so Apache would have ignored them. They are now on their own lines. - The quotes inside the
CustomLogformat string are now escaped (\"). Without this, Apache reads the first inner quote as the end of the string and reports a syntax error. - Replace
www.yourname.comwith your own domain name, and replace the three Passenger lines with the ones printed in step 12.
rotatelogs writes a new log file each day (86400 seconds), so the logs do not grow forever.
14. Edit the main Apache configuration
vi /etc/httpd/conf/httpd.conf- Uncomment (remove the
#from)NameVirtualHost *:80. The original said*.80; it must be a colon. - Uncomment, or add,
Include conf.d/redmine.conf.
Added note: the default CentOS 6 httpd.conf already contains Include conf.d/*.conf, which loads every .conf file in conf.d, including redmine.conf. If that line is present you do not need a separate include line.
15. Give Apache permission on the Redmine folder
chown -R apache:root /var/www/redminehttpd -thttpd -t checks the Apache configuration for syntax errors without restarting. If it prints Syntax OK, restart Apache to load the new configuration:
service httpd restartThen open http://www.yourname.com/ (your domain) in a browser. On Redmine the default administrator login is admin with password admin; change it straight away.
That’s it, good luck.
Notes for today
-
CentOS 6 is end of life. It reached end of life on 30 November 2020 and gets no security updates. Rocky Linux and AlmaLinux are the common free replacements; Debian and Ubuntu are alternatives.
-
Redmine 1.4 is very old. Current Redmine releases need a modern Ruby and use different setup commands (for example,
generate_session_storewas replaced in later versions). Follow the official installation guide for the version you download: https://www.redmine.org/ -
Commands on newer systems:
service mysqld startbecamesystemctl start mysqld(ormariadbon systems that ship MariaDB). Usesystemctl enableto start it at boot.yumbecamednfon newer Red Hat-family systems (yumstill works as an alias).iptablesservice scripts becamefirewalld. To open HTTP:sudo firewall-cmd --permanent --add-service=httpthensudo firewall-cmd --reload.
-
MySQL 8.0 no longer accepts
IDENTIFIED BYinsideGRANT. Create the user first, then grant:CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';For MySQL 8.0 and newer,
utf8mb4is the recommended character set rather thanutf8. -
Apache 2.4 (CentOS 7 and later) replaced
allow from allwithRequire all granted, andNameVirtualHostis no longer needed. -
SELinux: step 10 leaves this open. Disabling SELinux is a common shortcut but removes a layer of protection. Keep it enforcing where you can and fix the specific denial (check
/var/log/audit/audit.log) instead. -
Permissions:
chown -R apache:rootgives the web server ownership of every Redmine file, including the configuration that holds the database password. It works, but a tighter setup only lets Apache write to the directories Redmine needs to write to (such asfiles,logandtmp).