deles 发表于 2019-2-15 17:25:40

CentOS 6.6上安装配置Redmine

Redmine versionSupported Ruby versionsRails version used4.0 (upcoming)ruby 2.2 (2.2.2 and later), 2.3, 2.41, 2.5Rails 5.23.4ruby 1.9.34, 2.0.03, 2.1, 2.22, 2.3, 2.41Rails 4.23.3ruby 1.9.34, 2.0.03, 2.1, 2.22, 2.3Rails 4.2本次安装版本:redmine 3.4.6 、ruby2.4.4、rails4.2、mysql 5.7.19
环境初始化: yum install -y make gcc gcc-c++ lrzszncurses-devel cmake    libxml2 libxslt libxml2-devel libxslt-devel openssl-develzlib-develImageMagick ImageMagick-devel
禁用SELINUX : sed -ri 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config


安装mysql
tar -zxf boost_1_59_0.tar.gz -C /usr/local/&& cd /usr/local && ln -s boost_1_59_0 boost
tar -zxf mysql-5.7.19.tar.gz
cd mysql-5.7.19
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_EXTRA_CHARSETS=complex -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
/usr/local/mysql/bin/mysql_secure_installation


安装Ruby
wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.4.tar.gz
tar -zxf ruby-2.4.4.tar.gz
cd ruby-2.4.4
./configure
make && make install



安装Rails
gem sources -l
可更换gem源为https://ruby.taobao.org/ 或 https://gems.ruby-china.org/
gem update --system #更新gem
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/ #切换至国内源
gem install rails -v 4.2


下载Redmine
wget http://www.redmine.org/releases/redmine-3.4.6.tar.gz
tar -zxf redmine-3.4.6.tar.gz
mv redmine-3.4.6 /usr/local/


创建数据库
mysql -h localhost -u root -p
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';


修改配置文件
cp /usr/local/redmine/config/database.yml.example /usr/local/redmine/config/database.yml
vi database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "123456"
encoding: utf8
socket: /usr/local/mysql/mysql.sock


安装依赖程序
gem install bundler
bundle config mirror.https://rubygems.org https://gems.ruby-china.org
bundle install --without development test


创建数据库表及默认设置
cd /usr/local/redmine
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production REDMINE_LANG=zh bundle exec rake redmine:load_default_data


为Rails生成cookies秘钥
bundle exec rake generate_secret_token


创建相关目录及权限设置
mkdir -p tmp tmp/pdf public/plugin_assets
chown -R nobody:nobody files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets


启动Redmine
cd /usr/local/redmine
bundle exec rails server webrick -e production -b 0.0.0.0 -d
默认端口为3000,访问http://ip:3000,默认管理员为admin/admin


安装PhusionPassenger和Nginx
gem install passenger
passenger-install-nginx-module


http://s1.运维网.com/images/20180927/1538028138767937.png
http://s1.运维网.com/images/20180927/1538028151130082.png
遇到如下错误是因为openssl版本太高的原因,折腾了我好久。我的openssl编译安装版本是openssl-1.1.0g,uninstall卸载编译
安装的版本,使用centos6.6 yum安装的默认版本openssl-1.0.1e可以正常编译nginx扩展passenger
http://s1.运维网.com/images/20180927/1538028217586619.png




http://s1.运维网.com/images/20180927/1538028230311306.png


NGINX配置
  user nobody;
  worker_processes auto;
  worker_cpu_affinity auto;
  worker_rlimit_nofile 20480;
  error_log logs/error.log;
  pid logs/nginx.pid;
  events {
      worker_connections 10240;
      use epoll;
  }
  http {
      server_tokens off;
      server_names_hash_bucket_size 128;
      server_names_hash_max_size 1024;
      client_max_body_size 10m;
      client_header_buffer_size 16k;
      large_client_header_buffers 4 16k;
      default_typeapplication/octet-stream;
      include mime.types;
      passenger_root /usr/local/lib/ruby/gems/2.4.0/gems/passenger-5.3.5;
      passenger_ruby /usr/local/bin/ruby;
      open_file_cache max=65535 inactive=20s;
      open_file_cache_errors on;
      open_file_cache_min_uses 2;
      open_file_cache_valid 30s;
      log_not_found off;
      gzip on;
      gzip_vary on;
      gzip_http_version 1.0;
      gzip_buffers 4 8k;
      gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
      gzip_comp_level 2;
      gzip_min_length 1k;
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 60;
      log_formatmain'$remote_addr - $remote_user [$time_local $request_time] "$request" '
                        '$status $body_bytes_sent "$http_referer" "$content_type" "$request_body" '
                        '"$http_user_agent" "$upstream_addr" "$http_x_forwarded_for"';
        server {
        listen 80;
        server_name redmine.usc.com;
        access_log logs/access.log main;
        error_log logs/error.log;
        passenger_enabled on;
        
        location / {
              root /usr/local/redmine/public/;
              index index.html index.htm;
        }
        }
  }
  

  配置SendMail发送邮件
  yum install -y sendmail mail
  service sendmail start
  echo "hello world" >mail.txt
  mail -s &quot;mail from sendmail&quot; test123@163.com < mail.txt测试往邮箱发信是否能收到
  cp -p configuration.yml.example configuration.yml
  在production: 下面添加如下内容
      email_delivery:   
        delivery_method: :sendmail
  修改settings.yml配置mail_from为自己需要的邮件显示名称,然后重启nginx即可
  

  甘特图导出PNG图片中文乱码

  mkdir/usr/share/fonts/truetype/arphic && cd /usr/share/fonts/truetype/arphic
  wget https://ftp.gnu.org/non-gnu/chinese-fonts-truetype/gbsn00lp.ttf.gz
  gunzip gbsn00lp.ttf.gz
  修改configuration.yml配置为
  rmagick_font_path: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf
  

  安装Scrum插件
  进入/usr/local/redmine/plugins
  wget https://redmine.ociotec.com/attachments/download/476/scrum-v0.18.0.tar.gz
  tar -zxf scrum-v0.18.0.tar.gz
  bundle install
  bundle exec rake redmine:plugins:migrate RAILS_ENV=production
###########################################    相关错误解决方法###################################
make时报错(chmod +x Makefile):make: *** No rule to make target `/include/ruby.h', needed by `zlib.o'.Stop.


yum install zlib-devel
cd ruby-2.4.4/ext/zlib
ruby ./extconf.rb
vi Makefile 将zlib.o: $(top_srcdir)/include/ruby.h改成   zlib.o: ../../include/ruby.h;
make
make install


yum install openssl-devel
cd ruby-2.4.4/ext/openssl
ruby ./extconf.rb
vi Makefile
增加 top_srcdir = ../..
make
make install


  yum-config-manager --enable epel
  Traceback (most recent call last):
  File &quot;/usr/bin/yum-config-manager&quot;, line 6, in
      import yum
  ImportError: No module named yum
  修改/usr/bin/yum-config-manager 第一行为!/usr/bin/python2.6 -tt












页: [1]
查看完整版本: CentOS 6.6上安装配置Redmine