连接服务器
ssh root@192.168.31.133首先启动MariaDB
systemctl start mariadb查看MariaDB的状态
systemctl status mariadb设置开机启动
systemctl enable mariadb登陆mysql,默认密码为空,直接回车进入
mysql -u root -p创建redmine数据库
CREATE DATABASE redmine CHARACTER SET utf8; CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine'; GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';安装开发工具
yum groupinstall "Development tools" yum -y install zlib-devel curl-devel openssl-devel mysql-devel下载ruby-2.4.2
wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.gz编译安装ruby
tar -zxvf ruby-2.4.2.tar.gz cd ruby-2.4.2/ sudo ./configure sudo make sudo make install配置gem源
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ gem sources -l参考
http://www.redmine.org/projects/redmine/wiki/RedmineInstall
下载Redmine
cd ~ wget http://www.redmine.org/releases/redmine-3.4.3.tar.gz解压redmine包
tar -zxvf redmine-3.4.3.tar.gz将redmine移动到/var目录下
mv redmine-3.4.3 /var/redmine拷贝 config/database.yml.example 为 config/database.yml
cd /var/redmine/config/ cp database.yml.example database.yml编辑数据库配置文件
vi database.yml 配置数据库 production: adapter: mysql2 database: redmine host: localhost username: redmine password: "redmine" encoding: utf8安装bundle
cd /var/redmine gem install bundler配置bundler源
bundle config mirror.https://rubygems.org https://gems.ruby-china.org安装redmine依赖
bundle install --without development test rmagick初始化数据库
# 生成秘钥 bundle exec rake generate_secret_token # 初始化数据库 RAILS_ENV=production bundle exec rake db:migrate用以下命令配置为中文,输入zh
RAILS_ENV=production bundle exec rake redmine:load_default_data设置权限
# 创建目录 mkdir -p tmp tmp/pdf public/plugin_assets # 设置权限 sudo chmod -R 755 files log tmp public/plugin_assets测试运行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.133Puma参考
https://github.com/puma/puma
添加gem puma到Gemfile
cd /var/redmine/ vi Gemfile 添加puma gem "puma"重新运行安装依赖
bundle install --without development test rmagick配置puma.rb
vi config/puma.rb 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 60运行
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 restart访问http://192.168.31.133/
