Linux上安装Redmine
安装基本的软件环境
# yum install zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
安装MySQL
添加mysql源
# CentOS6
# rpm -Uvh http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm
# CentOS7
# rpm -Uvh http://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm
安装mysql
# yum install mysql-community-server
设置自启,并启动mysql服务
# chkconfig mysqld on
# service mysqld start
查看安装完成后生成的root临时密码
# grep 'temporary password' /var/log/mysqld.log
运行mysql安全配置
# mysql_secure_installation
安装PHP、php-fpm和phpMyAdmin
安装php、php-fpm和相关扩展包
# yum install php php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-pecl-apc php-soap php-fpm
设置自启,并启动php-fpm服务
# chkconfig php-fpm on
# service php-fpm start
添加rpmforge源
# CentOS6
# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# CentOS7
# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
安装phpMyAdmin
# yum install phpmyadmin
修改phpMyAdmin虚拟目录配置文件,允许远程访问
# vi /etc/httpd/conf.d/phpmyadmin.conf
(Apache 2.2) 把 "Allow from 127.0.0.1" 修改为 "Allow from all"
Allow from all
(Apache 2.4) 添加 "Require all granted"
Require all granted
修改phpMyAdmin配置文件config.inc.php,将认证方式 'cookie' 改为 'http'
$cfg['Servers'][$i]['auth_type'] = 'http';
方式一:Apache下使用php-fpm运行php
安装Apache
# yum install httpd
修改php apache配置文件
# vi /etc/httpd/conf.d/php.conf
如果php-fpm使用的是TCP socket
<FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch>
如果用的是unix socket
<Proxy "unix:/var/run/php-fpm/php-fpm.sock|fcgi://php-fpm"> ProxySet disablereuse=off </Proxy> <FilesMatch \.php$> SetHandler proxy:fcgi://php-fpm </FilesMatch>
设置自启,并启动apache服务
# chkconfig httpd on
# service httpd start
方式二:Nginx下使用php-fpm运行php
添加nginx源
# vi /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1
根据操作系统类型,替换 “OS
” 为 “rhel
” 或 “centos
”,“OSRELEASE
” 为 “5
”, “6
”, 或 “7
”
安装Nginx
# yum install nginx
修改nginx配置文件
# vi /etc/nginx/nginx.conf
如果php-fpm使用的是TCP socket
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ {
try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
如果用的是unix socket
# pass the PHP scripts to FastCGI server listening on unix:/var/run/php-fpm/php-fpm.sock location ~ \.php$ {
try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
安装Ruby
安装ruby版本管理器RVM
# \curl -sSL https://get.rvm.io | bash # source /etc/profile.d/rvm.sh
列出所有ruby版本
# rvm list known
Redmine 3.2不支持Ruby 2.3,所以安装Ruby 2.2
# rvm install 2.2
检查ruby版本
# ruby -v
安装Rubygems(Ruby包管理器)
# yum install rubygems
Apache下安装Passenger
# gem install passenger --no-ri --no-rdoc # passenger-install-apache2-module
命令执行完后按照提示进行配置passenger的虚拟目录文件
# vi /etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.3.1/gems/passenger-5.0.28/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c> PassengerRoot /usr/local/rvm/gems/ruby-2.3.1/gems/passenger-5.0.28 PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.3.1/wrappers/ruby </IfModule>
为Redmine创建空数据库和用户
登陆mysql
# mysql -u root -p
进行相关数据库配置
mysql> CREATE DATABASE redmine CHARACTER SET utf8; mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password'; mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
安装Redmine
下载Redmine
# cd /var/www # wget http://www.redmine.org/releases/redmine-3.2.2.tar.gz
解压并重命名文件夹
# tar xfz redmine-3.2.2.tar.gz # mv redmine-3.2.2 redmine # rm -rf redmine-3.2.2.tar.gz
配置redmine数据库连接字符串
# cd /var/www/redmine/config # cp database.yml.example database.yml
# vi database.yml
production: adapter: mysql2 database: redmine host: localhost username: redmine password: "my_password" encoding: utf8
安装依赖包(使用依赖包管理工具Bundler)
# cd /var/www/redmine # gem install bundler # bundle install --without development test
为了提高下载gem包速度,可以使用国内的淘宝源,你可以用 Bundler 的 Gem 源代码镜像命令
# bundle config mirror.https://rubygems.org https://ruby.taobao.org
生成安全Token
# bundle exec rake generate_secret_token
创建redmine数据库表
# RAILS_ENV=production bundle exec rake db:migrate
# RAILS_ENV=production bundle exec rake redmine:load_default_data
激活FCGI
# cd /var/www/redmine/public # cp dispatch.fcgi.example dispatch.fcgi # cp htaccess.fcgi.example .htaccess
安装mod_fcgi
# yum install epel-release (安装epel源)
# yum install mod_fcgid
Redmine配置
# cd /var/www/redmine/config # cp -v configuration.yml.example configuration.yml
(可选)更改附件文件存放路径
# mkdir -p /opt/redmine/files # chown -R apache:apache /opt/redmine
# vi configuration.yml
attachments_storage_path: /opt/redmine/files
(可选)配置日志
# cp -v additional_environment.rb.example additional_environment.rb
# vi additional_environment.rb
#Logger.new(PATH,NUM_FILES_TO_ROTATE,FILE_SIZE) config.logger = Logger.new('/path/to/logfile.log', 2, 1000000) config.logger.level = Logger::INFO
(可选)配置Email(sendmail方式)
# vi configuration.yml
production:
email_delivery:
delivery_method: :sendmail
给Redmine创建虚拟目录
# vi /etc/httpd/conf.d/redmine.conf
Alias /redmine /var/www/redmine/public <Location /redmine> PassengerBaseURI /redmine PassengerAppRoot /var/www/redmine PassengerRuby /usr/local/rvm/gems/ruby-2.2.5/wrappers/ruby </Location> <Directory /var/www/redmine/public> Allow from all Options -MultiViews # Uncomment this if you're on Apache >= 2.4: #Require all granted </Directory>
启动Redmine
# cd /var/www # chown -R apache:apache redmine # chmod -R 755 redmine # service httpd restart