CentOS 7.6上安裝專案管理系統 Redmine 3.4.7

這個月發生了兩件大事,其一是CentOS release了7.6的版本,其二是Redmine版本推進至4.0.0,由於這個版本在前端視覺設計上感覺還有些小問題,與佈景主題的搭配上也不太合,故本篇以12/9同時發行的3.4.7版本來做安裝的筆記(4.0.0的安裝方法也是一樣的唷)


  • CentOS Linux release 7.6.1810 (Core)
  • Apache 2.4
  • Apache Passenger 6.0.0
  • Ruby 2.4.5
  • Redmine 3.4.7.stable

1. MySQL 安裝設定

[root@centos76 ~]# yum localinstall -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@centos76 ~]# yum install mysql-community-server mysql-community-devel
[root@centos76 ~]# systemctl start mysqld.service
[root@centos76 ~]# systemctl enable mysqld.service

[root@centos76 ~]# grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1

2018-12-14T08:00:08.063711Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >wg4iH>/<%C%

[root@centos76 ~]# /usr/bin/mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root: 輸入上面那段random密碼

The existing password for the user account root has expired. Please set a new password.

New password: 輸入你想要設定的新密碼

Re-enter new password: 重複吧!
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...

 - Removing privileges on test database...

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done!

[root@centos76 ~]# mysql -h localhost -u root -p
Enter password: 輸入剛替DB的root帳戶設定的新密碼
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE redmine CHARACTER SET utf8mb4;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE USER 'redmine_user'@'localhost' IDENTIFIED BY '11223344@Pig';
Query OK, 0 rows affected (0.04 sec)

mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine_user'@'localhost';
Query OK, 0 rows affected (0.07 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> quit

2. Ruby 2.4.X 安裝設定

[root@centos76 ~]# yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-dev make bzip2 autoconf automake libtool bison iconv-devel sqlite-devel

[root@centos76 ~]# curl -sSL https://rvm.io/mpapis.asc | gpg --import -
[root@centos76 ~]# curl -L get.rvm.io | bash -s stable

如果你出現以下訊息,請依照系統提示改為輸入以下指令來安裝 RVM。
gpg: Signature made Thu 13 Dec 2018 11:09:53 PM CST using RSA key ID 39499BDB
gpg: Can't check signature: No public key
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
[root@centos76 ~]# curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
[root@centos76 ~]# curl -L get.rvm.io | bash -s stable
[root@centos76 ~]# source /etc/profile.d/rvm.sh
[root@centos76 ~]# rvm reload
RVM reloaded!

[root@centos76 ~]# rvm requirements run

安裝Ruby 2.4.x、並檢查Ruby版本,我在安裝的當下已經發布了Ruby 2.4.5
[root@centos76 ~]# rvm list
=* ruby-2.4.5 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

[root@centos76 ~]# ruby --version
ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]

[root@centos76 ~]# export GEMS=/usr/local/rvm/gems/ruby-2.4.5/gems

3. Apache 安裝設定

[root@centos76 ~]# yum install httpd-devel libcurl-devel apr-devel apr-util-devel mod_ssl
[root@centos76 ~]# systemctl enable httpd

4. Redmine 安裝設定

[root@centos76 ~]# yum install ImageMagick ImageMagick-devel

[root@centos76 ~]# cd /var/www
[root@centos76 www]# wget http://www.redmine.org/releases/redmine-3.4.7.zip
[root@centos76 www]# unzip ./redmine-3.4.7.zip
[root@centos76 www]# mv ./redmine-3.4.7 /var/www/redmine
[root@centos76 www]# chown -R apache:apache /var/www/redmine
[root@centos76 www]# export REDMINE=/var/www/redmine
[root@centos76 www]# cd $REDMINE

[root@centos76 redmine]# cp config/database.yml.example config/database.yml
[root@centos76 redmine]# nano config/database.yml

# Default setup is given for MySQL with ruby1.9.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).

  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine_user
  password: "11223344@Pig"
  encoding: utf8
[root@centos76 ~]# cd $REDMINE
[root@centos76 redmine]# gem install bundler
[root@centos76 redmine]# bundle install --without development test

5. Apache Passenger 安裝設定

安裝Passenger套件後,可以讓Apache與Ruby on Rails的網頁溝通界接
[root@centos76 ~]# cd $REDMINE
[root@centos76 redmine]# gem install passenger

Phusion Passenger Apache2模組安裝,路徑請參照你系統所安裝的passenger版本
[root@centos76 redmine]# $GEMS/passenger-6.0.0/bin/passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v6.0.0.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort. 按下Enter鍵

Installation through RPMs recommended

It looks like you are on a Red Hat or CentOS operating system, with SELinux
enabled. SELinux is a security mechanism for which special Passenger-specific
configuration is required. We supply this configuration as part of
our Passenger RPMs.

However, Passenger is currently installed through gem or tarball and does not
include any SELinux configuration. Therefore, we recommend that you:

 1. Uninstall your current Passenger install.
 2. Reinstall Passenger through the RPMs that we provide:

What would you like to do?

Press Ctrl-C to exit this installer so that you can install RPMs (recommended)
Press Enter to continue using this installer anyway 按下Enter鍵

Which languages are you interested in?

Use <space> to select.
If the menu doesn't display correctly, press '!'

》  Ruby 預設就是ruby,直接按下Enter鍵
Almost there!

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/rvm/gems/ruby-2.4.5/gems/passenger-6.0.0/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rvm/gems/ruby-2.4.5/gems/passenger-6.0.0
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.4.5/wrappers/ruby

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER when you are done editing. 按下Enter鍵

[root@centos76 redmine]# nano /etc/httpd/conf.modules.d/pasenger.conf

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.4.5/gems/passenger-6.0.0/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rvm/gems/ruby-2.4.5/gems/passenger-6.0.0
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.4.5/wrappers/ruby
新增一個網站設定檔for REDMINE
[root@centos76 redmine]# nano /etc/httpd/conf.d/redmine.conf

    <VirtualHost *:80>
        ServerName youserver.domain.org
        DocumentRoot "/var/www/redmine/public" 

        ErrorLog logs/redmine_error_log
        LogLevel warn

        <Directory "/var/www/redmine/public">
            Options Indexes ExecCGI FollowSymLinks
            Require all granted
            AllowOverride all
調整防火牆讓外部可存取Apache web service
[root@centos76 ~]# systemctl restart httpd
[root@centos76 ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
[root@centos76 ~]# firewall-cmd --permanent --zone=public --add-port=443/tcp
[root@centos76 ~]# firewall-cmd --reload

[root@centos76 ~]# setenforce 0
[root@centos76 ~]# nano /etc/sysconfig/selinux 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.

6. 準備進入REDMINE

[root@centos76 ~]# cd $REDMINE
[root@centos76 redmine]# RAILS_ENV=production bundle exec rake generate_secret_token
[root@centos76 redmine]# RAILS_ENV=production bundle exec rake db:migrate
[root@centos76 redmine]# RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data




來自台灣的系統工程師,一直熱衷於 Open source 相關技術的學習、建置、應用與分享。

  • Image
  • Image
  • Image
  • Image
  • Image