一安装Mysql
CentOS6.9+Mysql5.7.18源码安装
二、安装基本软件环境依赖包
yum install 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
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel \
libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel \
curl-devel openssl-devel pcre-devel mysql-devel ImageMagick-devel ImageMagick gcc-c++ gcc c
三、安装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
安装phpMyAdmin
yum install phpmyadmin
四、安装Rubby
cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.3.1.tar.gz
tar -zxvf ruby-2.3.1.tar.gz
cd ruby-2.3.1
./configure
make && make install
检查Ruby是否安装成功:
ruby -v
五、安装Rubygems(Ruby包管理器)
为了提高下载gem包速度,可以使用国内的淘宝源,你可以用 Bundler 的 Gem 源代码镜像命令
bundle config mirror.https://rubygems.org https://ruby.taobao.orgcd /usr/local/src
wget https://rubygems.org/rubygems/rubygems-2.6.8.tgz
tar -zxvf rubygems-2.6.8.tgz
cd rubygems-2.6.8
/usr/local/bin/ruby setup.rb
检查gem是否安装成功
gem -v
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
gem install bundler
gem install rmagick
gem install rails --no-document -v='4.2.7'
gem install rake --no-document
gem i mime-types --no-document
gem install nokogiri -- --use-system-libraries
gem install rbpdf --no-document
gem install rbpdf-font --no-document
gem install mysql2
六、安装Redmine3.3.3
Apache下安装Passenger用于部署rails应用
gem install passenger --no-ri --no-rdoc
passenger-install-apache2-module
命令执行完后按照提示进行配置passenger的虚拟目录文件
vi /etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.5/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.5
PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>
为Redmine创建空数据库和用户
登陆mysql
mysql -u root -p
进行相关数据库配置
mysql> CREATE DATABASE redmine CHARACTER SET utf8;
mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';
mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
下载redmine
cd /usr/local/src
wget http://www.redmine.org/releases/redmine-3.3.3.tar.gz
tar -zxf redmine-3.3.3.tar.gz
mv redmine-3.3.3 /opt/
cd /opt/redmine-3.3.3
bundle config build.nokogiri --use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2
bundle install --without development test
vim config/database.yml
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "redmine"
encoding: utf8
生成安全Token
# bundle exec rake generate_secret_token
创建redmine数据库表
RAILS_ENV=production bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data
激活FCGI
cd /opt/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 /opt/redmine/config cp configuration.yml.example configuration.yml vi configuration.ymlattachments_storage_path: /opt/redmine/files
更改附件文件存放路径
mkdir -p /opt/redmine/files chown -R apache:apache /opt/redmine配置日志
vi additional_environment.rbcp -v additional_environment.rb.example additional_environment.rb
#Logger.new(PATH,NUM_FILES_TO_ROTATE,FILE_SIZE) config.logger = Logger.new('/opt/redmine/logs/logfile.log', 2, 1000000) config.logger.level = Logger::ERROR配置Email(sendmail方式)
email_delivery: delivery_method: :smtp smtp_settings: address: xxxxxxxx.com port: 587 domain: example.net authentication: :login user_name: services@qq.com password: xxxxxxx
给Redmine创建虚拟目录
# vi /etc/httpd/conf.d/redmine.conf
Alias /redmine /opt/redmine-3.3.3/public <Location /redmine> PassengerBaseURI /redmine PassengerAppRoot /opt/redmine PassengerRuby /usr/local/bin/ruby </Location> <Directory /opt/redmine-3.3.3/public> Allow from all Options -MultiViews # Uncomment this if you're on Apache >= 2.4: #Require all granted </Directory>
ln -s /opt/redmine-3.3.3 /opt/redmine
启动Redmine
cd /opt chown -R apache:apache redmine-3.3.3 chmod -R 755 redmine-3.3.3service httpd restartbundle exec rails server webrick -e production
apache启动报错:Permission denied: make_sock: could not bind to address时执行:
setenforce 0
cd /opt/redmine-3.3.3/
nohup bundle exec rails server webrick -p3000 -b 0.0.0.0 -e production >/dev/null 2>&1 &
查进程:
ps -ef|grep rails
root 1777 16051 5 14:43 pts/2 00:00:02 /usr/local/bin/ruby bin/rails server webrick -p3000 -b 0.0.0.0 -e production
让 Apache 支持 cgi
vi /etc/httpd/conf/httpd.conf
- Options Indexes FollowSymLinks ( 找到这一行,删除“ Indexes ”,并添加“ Includes ”、“ ExecCGI ” )
- Options Includes ExecCGI FollowSymLinks ( 允许服务器执行 CGI 及 SSI)
- #AddHandler cgi-script .cgi ( 找到这一行,去掉行首的“ # ”,并在行尾添加“ .pl ” )
- AddHandler cgi-script .cgi .pl ( 允许扩展名为 .pl 的 CGI 脚本运行 )