ubuntu 部署 redmine

Ubuntu 部署 Redmine

安装 ruby

sudo apt update
sudo apt install ruby-full
ruby --version # 查看 ruyby 版本
gem -v # 查看 gem 版本
# gem 更换淘宝源
gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
# gem ruby-china 镜像
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/

安装 MySQL

# 安装 MySQL 服务
sudo apt install mysql-server
# 修改 root 密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root_password';
# 初始化密码及一下安全设置,密码强度建议选 2 ,其它项全选 y
sudo mysql_secure_installation
# 访问 MySQL,不加 sudo 会报错:ERROR 1698 (28000): Access denied for user 'root'@'localhost'
sudo mysql -uroot -p
# 执行下面 3 条指令
CREATE DATABASE redmine CHARACTER SET utf8mb4;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';

# 操作命令
sudo systemctl start mysql.service 		# 开启
sudo systemctl restart mysql.service	# 重启
sudo systemctl stop mysql.service		# 停止
sudo systemctl enable mysql.service 	# 开机启动

下载并部署 Redmine

# 依赖安装
sudo apt install -y libmysqlclient-dev libmagickwand-dev  imagemagick           
cd /opt/www # 根据自己情况存放
sudo wget https://www.redmine.org/releases/redmine-5.0.2.tar.gz
sudo tar zxvf redmine-5.0.2.tar.gz
cd redmine-5.0.2

修改数据库配置文件

cp config/database.yml.example config/database.yml
# 修改数据库配置文件
sudo vim config/database.yml
production:
    adapter: mysql2
    database: redmine
    host: localhost
    username: redmine
    password: "my_password
    
# 安装
bundle install --without development test

创建 config/secrets.yml

# 生成 config/initializers/secret_token.rb 文件
rake generate_secret_token

# 获取 secret_key_base
cat config/initializers/secret_token.rb

# 创建 config/secrets.yml 并复制 secret_key_base 至 production - secret_key_base 处
vim config/secrets.yml
development:
    secret_key_base:

test:
    secret_key_base:

production:
    secret_key_base: 'b412935c5e7d4042aefaf0659e4529832d429e66cededb5d8aca47f05ccd08d2127dff59e8c1d633'

导入数据库数据

rake db:migrate RAILS_ENV="production"

文件夹授权

# 添加 redmine 组
sudo groupadd -r redmine
# 创建 redmine 并加入到 redmine 组,不允许 redmine 用户直接登录系统
sudo useradd -s /sbin/nologin -g redmine -r redmine
sudo chown -R redmine:redmine files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

运行服务

sudo ruby bin/rails server -e production

访问服务

# 浏览器输入:http://ip_address:3000
http://192.168.0.21:3000 # 本地测试服务器地址
用户名:admin
密码:admin

你可能感兴趣的:(Linux,Tools,ubuntu,redmine,ruby,bug,linux,redmine)