Install Redmine on CentOS7
CentOS 7安装Redmine
https://blog.csdn.net/h1101723183/article/details/80954587
环境
- CentOS 7
- MariaDB
- Ruby 2.4.2
- Redmine 3.4.3
- Puma
连接服务器
-
连接服务器
ssh root@192.168.31.1331
启动MariaDB
-
首先启动MariaDB
systemctl start mariadb1
-
查看MariaDB的状态
systemctl status mariadb1
-
设置开机启动
systemctl enable mariadb1
-
登陆mysql,默认密码为空,直接回车进入
mysql -u root -p 1
-
创建redmine数据库
CREATE DATABASE redmine CHARACTER SET utf8; CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine'; GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';123
安装Ruby
-
安装开发工具
yum groupinstall "Development tools" yum -y install zlib-devel curl-devel openssl-devel mysql-devel12
-
下载ruby-2.4.2
wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.gz1
-
编译安装ruby
tar -zxvf ruby-2.4.2.tar.gz cd ruby-2.4.2/ sudo ./configure sudo make sudo make install12345
-
配置gem源
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ gem sources -l12
安装Redmine
-
参考
-
下载Redmine
cd ~ wget http://www.redmine.org/releases/redmine-3.4.3.tar.gz12
-
解压redmine包
tar -zxvf redmine-3.4.3.tar.gz1
-
将redmine移动到/var目录下
mv redmine-3.4.3 /var/redmine1
-
拷贝 config/database.yml.example 为 config/database.yml
cd /var/redmine/config/ cp database.yml.example database.yml12
-
编辑数据库配置文件
vi database.yml1
- 配置数据库
production: adapter: mysql2 database: redmine host: localhost username: redmine password: "redmine" encoding: utf81234567
-
安装bundle
cd /var/redmine gem install bundler12
-
配置bundler源
bundle config mirror.https://rubygems.org https://gems.ruby-china.org1
-
安装redmine依赖
bundle install --without development test rmagick1
-
初始化数据库
# 生成秘钥 bundle exec rake generate_secret_token # 初始化数据库 RAILS_ENV=production bundle exec rake db:migrate123456789
-
用以下命令配置为中文,输入zh
RAILS_ENV=production bundle exec rake redmine:load_default_data1
-
设置权限
# 创建目录 mkdir -p tmp tmp/pdf public/plugin_assets # 设置权限 sudo chmod -R 755 files log tmp public/plugin_assets123456789
-
测试运行redmine
bundle exec rails server webrick -e production # e.g,我的主机是192.168.31.133,用以下命令绑定80端口 bundle exec rails server webrick -e production -p 80 -b 192.168.31.133123456
使用puma运行redmine
-
Puma参考
-
添加gem puma到Gemfile
cd /var/redmine/ vi Gemfile12
- 添加puma
gem "puma"1
-
重新运行安装依赖
bundle install --without development test rmagick1
-
配置puma.rb
vi config/puma.rb1
- puma.rb
#!/usr/bin/env puma # The directory to operate out of. # # The default is the current directory. # directory '/var/redmine' # Set the environment in which the rack's app will run. The value must be a string. # # The default is "development". # environment 'production' # Daemonize the server into the background. Highly suggest that # this be combined with "pidfile" and "stdout_redirect". # # The default is "false". # # daemonize daemonize true # Store the pid of the server in the file at "path". # pidfile '/var/redmine/tmp/pids/puma.pid' # Use "path" as the file to store the server info state. This is # used by "pumactl" to query and control the server. # state_path '/var/redmine/tmp/pids/puma.state' # Redirect STDOUT and STDERR to files specified. The 3rd parameter # ("append") specifies whether the output is appended, the default is # "false". # stdout_redirect '/var/redmine/log/stdout.log', '/var/redmine/log/stderr.log' # stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr', true # Configure "min" to be the minimum number of threads to use to answer # requests and "max" the maximum. # # The default is "0, 16". # threads 2, 32 # Bind the server to "url". "tcp://", "unix://" and "ssl://" are the only # accepted protocols. # # The default is "tcp://0.0.0.0:9292". # # bind 'tcp://0.0.0.0:9292' # bind 'unix:///var/run/puma.sock' # bind 'unix:///var/run/puma.sock?umask=0111' # bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert' # 绑定80端口 bind 'tcp://0.0.0.0:80' # How many worker processes to run. Typically this is set to # to the number of available cores. # # The default is "0". # workers 3 # Preload the application before starting the workers; this conflicts with # phased restart feature. (off by default) preload_app! # Verifies that all workers have checked in to the master process within # the given timeout. If not the worker process will be restarted. This is # not a request timeout, it is to protect against a hung or dead process. # Setting this value will not protect against slow requests. # Default value is 60 seconds. # worker_timeout 60123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
-
运行
cd /var/redmine # 运行 bundle exec puma -C config/puma.rb # 停止 bundle exec pumactl --state tmp/pids/puma.state stop # 重启 bundle exec pumactl --state tmp/pids/puma.state restart12345678910111213141516