專案

一般

個人檔案

動作

如何在 Ubuntu 20.04/22.04 上使用 Apache2 安裝 Redmine 5.0.x

基於 Redmine 安裝指南,但僅限於 Ubuntu 和 MySQL,這將在空的 Ubuntu 20.04 虛擬機器上進行,這將使用 Apache2 和本地 MySQL 資料庫安裝 Redmine 5.0.1。如有任何問題或回饋,請隨時寫信至

安裝相依套件

# update & upgrade 
sudo apt-get update && sudo apt-get upgrade -y

# install required packages
sudo apt install -y apache2 ruby ruby-dev build-essential libapache2-mod-passenger libmysqlclient-dev

# if you want to install mysql server locally
sudo apt install -y mysql-server

下載並解壓縮 Redmine

這裡 取得最新版本。在此範例中,它將是 5.0.1

# download and extract
cd
wget https://redmine.org/releases/redmine-5.0.1.tar.gz
cd /opt
sudo tar -xvzf ~/redmine-5.0.1.tar.gz

# symlink to remove version reference
sudo ln -s redmine-5.0.1 redmine

設定資料庫

建立資料庫並為 Redmine 建立使用者。以下為本機安裝範例

sudo mysql

mysql> 
CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'secretPassword';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;

編輯資料庫設定檔

# copy the example file
cd /opt/redmine
cp config/database.yml.example config/database.yml

# edit config file with your editor of choice (mine is vi)
vi config/database.yml

使用您的設定替換或更新 production: 區塊。以下為基於上述 MySQL 設定的一個範例。

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "secretPassword" 
  # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
  encoding: utf8mb4

安裝 Ruby 相依套件

在 Redmine 路徑中

# install bundler
sudo gem install bundler

# install redmine bundle (give sudo password when prompted)
bundle install # installation of 22.04 seems to require this to be executed as sudo

執行 Redmine 指令碼

# generate secret token
bundle exec rake generate_secret_token

# migrate database
RAILS_ENV=production bundle exec rake db:migrate

# load default data
RAILS_ENV=production bundle exec rake redmine:load_default_data

設定 Apache

在 /etc/apache2/sites-available 中建立 Apache 設定檔(例如 redmine.conf),內容如下

<VirtualHost *:80>
    ServerName redmine.example.com
    RailsEnv production
    DocumentRoot /opt/redmine/public

    <Directory "/opt/redmine/public">
            Allow from all
            Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/redmine_error.log
        CustomLog ${APACHE_LOG_DIR}/redmine_access.log combined
</VirtualHost>

如果這是新的獨立安裝,則會建立預設的 Apache 站點。請停用它並啟用上面建立的 Redmine 設定。

# disable default apache sites
sudo a2dissite 000-default.conf

# enable redmine
sudo a2ensite redmine.conf

# reload apache
sudo systemctl reload apache2

測試 Redmine

將您的瀏覽器指向伺服器的 IP/DNS 名稱,它應該會顯示預設的 Redmine 畫面。
使用 admin/admin 登入

#party

Marc Morocutti 更新於 約 1 年前 · 11 個版本