安装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
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
为了提高下载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
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
PassengerRoot /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.5
PassengerDefaultRuby /usr/local/bin/ruby
为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
# bundle exec rake generate_secret_token
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
cd /opt/redmine/public cp dispatch.fcgi.example dispatch.fcgi cp htaccess.fcgi.example .htaccess
yum install epel-release (安装epel源) yum install mod_fcgid
cd /opt/redmine/config cp configuration.yml.example configuration.yml vi configuration.yml
attachments_storage_path: /opt/redmine/files
mkdir -p /opt/redmine/files chown -R apache:apache /opt/redmine
cp -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
# vi /etc/httpd/conf.d/redmine.conf
Alias /redmine /opt/redmine-3.3.3/publicPassengerBaseURI /redmine PassengerAppRoot /opt/redmine PassengerRuby /usr/local/bin/ruby Allow from all Options -MultiViews # Uncomment this if you're on Apache >= 2.4: #Require all granted
ln -s /opt/redmine-3.3.3 /opt/redmine
cd /opt chown -R apache:apache redmine-3.3.3 chmod -R 755 redmine-3.3.3
bundle exec rails server webrick -e production
service httpd restart
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