从头开始安装redmine项目管理软件

方嘉志
2023-12-01

redmine是采用ruby语言基于rails架构写的一款稳定高性能项目管理服务器,这里记录一下完整的安装过程。

注意:所有的操作都在普通用户中进行,不要使用root用户,如果需要高级别权限可以sudo命令执行。

第一步:
安装RVM软件,参考链接:http://www.rvm.io/
RVM称作Ruby Version Management,用于管理RUBY的版本功能,可以实现自动安装。可以输入rvm回车查看支持的命令,rvm list known 可以查看当前支持的版本。
[yangqiang@localhost ~]$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: requesting key 39499BDB from hkp server keys.gnupg.net
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <mpapis@gmail.com>" imported
gpg: key 39499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg: imported: 2 (RSA: 2)
[yangqiang@localhost ~]$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: Signature made Mon 11 Sep 2017 04:59:21 AM CST using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>"
gpg: aka "Michal Papis <michal.papis@toptal.com>"
gpg: aka "[jpeg image of size 5015]"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17 0311 3804 BB82 D39D C0E3
Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36 166B E206 C29F BF04 FF17
GPG verified '/home/yangqiang/.rvm/archives/rvm-1.29.3.tgz'

Installing RVM to /home/yangqiang/.rvm/
Adding rvm PATH line to /home/yangqiang/.profile /home/yangqiang/.mkshrc /home/yangqiang/.bashrc /home/yangqiang/.zshrc.
Adding rvm loading line to /home/yangqiang/.profile /home/yangqiang/.bash_profile /home/yangqiang/.zlogin.
Installation of RVM in /home/yangqiang/.rvm/ is almost complete:

  • To start using RVM you need to run source /home/yangqiang/.rvm/scripts/rvm
    in all your open shell windows, in rare cases you need to reopen all shell windows.
    [yangqiang@localhost ~]$ rvm -v
    -bash: rvm: command not found
    [yangqiang@localhost ~]$ source ~/.rvm/scripts/rmv
    -bash: /home/yangqiang/.rvm/scripts/rmv: No such file or directory
    使环境变量生效:
    [yangqiang@localhost ~]$ source /home/yangqiang/.rvm/scripts/rvm
    使用中国的镜像(可选):
    [yangqiang@localhost ~]$ echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > /home/yangqiang/.rvm/user/db
    [yangqiang@localhost ~]$ rvm –v //检查版本
    rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
    第二步:RUBY安装:
    RVM环境需求检查,会自动安装所需要的编译环境:
    [yangqiang@localhost ~]$ rvm requirements
    Checking requirements for centos.
    Installing requirements for centos.
    Installing required packages: autoconf, automake, bison, gcc-c++, libffi-devel, libtool, readline-devel, sqlite-devel, zlib-devel, libyaml-devel, openssl-devel..yangqiang password required for 'yum install -y autoconf automake bison gcc-c++ libffi-devel libtool readline-devel sqlite-devel zlib-devel libyaml-devel openssl-devel':
    yangqiang password required for 'yum install -y autoconf automake bison gcc-c++ libffi-devel libtool readline-devel sqlite-devel zlib-devel libyaml-devel openssl-devel':
    ..................
    Requirements installation successful.
    指定安装RUBY的版本,会同时安装ruby gems
    [yangqiang@localhost ~]$ rvm install 2.3.0
    Searching for binary rubies, this might take some time.
    Found remote file https://rvm_io.global.ssl.fastly.net/binaries/centos/6/x86_64/ruby-2.3.0.tar.bz2
    Checking requirements for centos.
    Requirements installation successful.
    ruby-2.3.0 - #configure
    ruby-2.3.0 - #download
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 21.9M 100 21.9M 0 0 73997 0 0:05:10 0:05:10 --:--:-- 62443
    No checksum for downloaded archive, recording checksum in user configuration.
    ruby-2.3.0 - #validate archive
    ruby-2.3.0 - #extract
    ruby-2.3.0 - #validate binary
    ruby-2.3.0 - #setup
    ruby-2.3.0 - #gemset created /home/yangqiang/.rvm/gems/ruby-2.3.0@global
    ruby-2.3.0 - #importing gemset /home/yangqiang/.rvm/gemsets/global.gems..............................
    ruby-2.3.0 - #generating global wrappers........
    ruby-2.3.0 - #gemset created /home/yangqiang/.rvm/gems/ruby-2.3.0
    ruby-2.3.0 - #importing gemsetfile /home/yangqiang/.rvm/gemsets/default.gems evaluated to empty gem list
    ruby-2.3.0 - #generating default wrappers........
    [yangqiang@localhost ~]$ ruby –v ruby版本查看
    ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
    [yangqiang@localhost ~]$ rubygem -v
    -bash: rubygem: command not found
    设置缺省的ruby版本号:
    [yangqiang@localhost ~]$ rvm use 2.3.0 --default
    Using /home/yangqiang/.rvm/gems/ruby-2.3.0
    [yangqiang@localhost ~]$ ruby -v
    ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
    查看gem的sources:
    [yangqiang@localhost ~]$ gem sources
    CURRENT SOURCES

https://rubygems.org/
更换GEM的source:
[yangqiang@localhost ~]$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
https://gems.ruby-china.org/ added to sources
https://rubygems.org/ removed from sources
[yangqiang@localhost ~]$ gem sources
CURRENT SOURCES

https://gems.ruby-china.org/
第三步:通过gem 安装bundler
[yangqiang@localhost ~]$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
Done installing documentation for bundler after 12 seconds
1 gem installed
第四步:通过gem安装rake
[yangqiang@localhost ~]$ gem install rake
Fetching: rake-12.3.0.gem (100%)
Successfully installed rake-12.3.0
Parsing documentation for rake-12.3.0
Installing ri documentation for rake-12.3.0
Done installing documentation for rake after 1 seconds
1 gem installed
第五步:通过gem安装rails
[yangqiang@localhost ~]$ gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
……
method_source, railties, sprockets, sprockets-rails, rails after 204 seconds
35 gems installed
[yangqiang@localhost ~]$
[yangqiang@localhost ~]$ cd /home/yangqiang/
l[yangqiang@localhost ~]$ ls
Desktop Downloads Pictures redmine-3.4.4.tar.gz Videos
Documents Music Public Templates
第六步:安装redmine
解压:
[yangqiang@localhost ~]$ tar zxvf redmine-3.4.4.tar.gz
redmine-3.4.4/
redmine-3.4.4/app/
redmine-3.4.4/app/models/
……
redmine-3.4.4/bin/rake
[yangqiang@localhost ~]$ ls
Desktop Downloads Pictures redmine-3.4.4 Templates
Documents Music Public redmine-3.4.4.tar.gz Videos
将解压后的目录放到/usr/local/,重命名为redmine
[yangqiang@localhost ~]$ mv redmine-3.4.4 /usr/local/redmine
mv: cannot move redmine-3.4.4' to/usr/local/redmine': Permission denied
[yangqiang@localhost ~]$ sudo mv redmine-3.4.4 /usr/local/redmine
[sudo] password for yangqiang:
[yangqiang@localhost ~]$ cd /usr/local/redmine/
[yangqiang@localhost redmine]$ ls
app config db files log Rakefile test
appveyor.yml config.ru doc Gemfile plugins README.rdoc tmp
bin CONTRIBUTING.md extra lib public script vendor
redmine数据库连接配置:
[yangqiang@localhost redmine]$ cd config //在config目录下面进行数据库配置
[yangqiang@localhost config]$ ls
additional_environment.rb.example database.yml.example locales
application.rb environment.rb routes.rb
boot.rb environments settings.yml
configuration.yml.example initializers
[yangqiang@localhost config]$ cp database.yml.example database.yml
[yangqiang@localhost config]$ vim database.yml //编辑数据库文件

//以下部分特别注意格式,production: 是顶格写,后面的是空两个字符,并且所有的关键字冒号后面带有一个空格,否则会报错。
production:
adapter: mysql2
database: redmine
host: localhost
username: root
password: ""
encoding: utf8

development:
adapter: mysql2
database: redmine_development
host: localhost
username: root
password: ""
encoding: utf8

"database.yml" 51L, 1144C written
第七步:安装mysql数据库:
[yangqiang@localhost config]$ sudo yum list all | grep mysqld
[yangqiang@localhost config]$ sudo yum list all | grep mysq*
mysql-libs.x86_64 5.1.73-8.el6_8 @anaconda-CentOS-201703281317.x86_64/6.9
apr-util-mysql.x86_64 1.3.9-3.el6_0.1 base
bacula-director-mysql.x86_64 5.0.0-13.el6 base
bacula-storage-mysql.x86_64 5.0.0-13.el6 base
dovecot-mysql.x86_64 1:2.0.9-22.el6 base
freeradius-mysql.x86_64 2.2.6-7.el6_9 updates
libdbi-dbd-mysql.x86_64 0.8.3-5.1.el6 base
mod_auth_mysql.x86_64 1:3.0.0-11.el6_0.1 base
mysql.x86_64 5.1.73-8.el6_8 base
mysql-bench.x86_64 5.1.73-8.el6_8 base
mysql-connector-java.noarch 1:5.1.17-6.el6 base
mysql-connector-odbc.x86_64 5.1.5r1144-7.el6 base
mysql-devel.i686 5.1.73-8.el6_8 base
mysql-devel.x86_64 5.1.73-8.el6_8 base
mysql-embedded.i686 5.1.73-8.el6_8 base
mysql-embedded.x86_64 5.1.73-8.el6_8 base
mysql-embedded-devel.i686 5.1.73-8.el6_8 base
mysql-embedded-devel.x86_64 5.1.73-8.el6_8 base
mysql-libs.i686 5.1.73-8.el6_8 base
mysql-server.x86_64 5.1.73-8.el6_8 base
mysql-test.x86_64 5.1.73-8.el6_8 base
pcp-pmda-mysql.x86_64 3.10.9-9.el6 base
php-mysql.x86_64 5.3.3-49.el6 base
qt-mysql.i686 1:4.6.2-28.el6_5 base
qt-mysql.x86_64 1:4.6.2-28.el6_5 base
rsyslog-mysql.x86_64 5.8.10-10.el6_6 base
rsyslog7-mysql.x86_64 7.4.10-7.el6 base
[yangqiang@localhost config]$ sudo yum -y install mysql-server.x86_64 mysql.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile

  • base: centos.ustc.edu.cn
  • extras: mirrors.nju.edu.cn
  • updates: mirrors.nju.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed
    ---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed
    --> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-8.el6_8.x86_64
    --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64
    --> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-8.el6_8.x86_64
    --> Running transaction check
    ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
    ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
    --> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size

===========

Installing:
mysql x86_64 5.1.73-8.el6_8 base 895 k
mysql-server x86_64 5.1.73-8.el6_8 base 8.6 M
Installing for dependencies:
perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k
perl-DBI x86_64 1.609-4.el6 base 705 k

Transaction Summary

Install 4 Package(s)

Total download size: 10 M
Installed size: 29 M
Downloading Packages:
(1/4): mysql-5.1.73-8.el6_8.x86_64.rpm | 895 kB 00:01
(2/4): mysql-server-5.1.73-8.el6_8.x86_64.rpm | 8.6 MB 00:11
(3/4): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00
(4/4): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:00

Total 745 kB/s | 10 MB 00:14
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-DBI-1.609-4.el6.x86_64 1/4
Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 2/4
Installing : mysql-5.1.73-8.el6_8.x86_64 3/4
Installing : mysql-server-5.1.73-8.el6_8.x86_64 4/4
Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/4
Verifying : mysql-server-5.1.73-8.el6_8.x86_64 2/4
Verifying : mysql-5.1.73-8.el6_8.x86_64 3/4
Verifying : perl-DBI-1.609-4.el6.x86_64 4/4

Installed:
mysql.x86_64 0:5.1.73-8.el6_8 mysql-server.x86_64 0:5.1.73-8.el6_8

Dependency Installed:
perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6

Complete!
[yangqiang@localhost config]$ mysql -v
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[yangqiang@localhost config]$ sudo mysql -v
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[yangqiang@localhost config]$ whereis mysqld
mysqld: /usr/libexec/mysqld /usr/share/man/man8/mysqld.8.gz
[yangqiang@localhost config]$ sudo service mysqld status
mysqld is stopped
数据库第三次启动会进行初始化:
[yangqiang@localhost config]$ sudo service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                       [  OK  ]

Starting mysqld: [ OK ]
[yangqiang@localhost config]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \q
Bye
[yangqiang@localhost config]$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[yangqiang@localhost config]$ vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~
~
~
~
~
~
~
~
~
~
~
~
[yangqiang@localhost config]$ sodo vim /etc/my.cnf
-bash: sodo: command not found
[yangqiang@localhost config]$ sudo vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0
safe_mysqld --skip-grant-tables & 增加该行跳过密码,修改完成密码后需要注释掉该行。
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/my.cnf" 12L, 286C written
[yangqiang@localhost config]$ service mysqld status
mysqld (pid 46873) is running...
[yangqiang@localhost config]$ service mysqld restart
Stopping mysqld: [FAILED]
Starting mysqld: [ OK ]
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$ service mysqld status
mysqld (pid 46873) is running...
[yangqiang@localhost config]$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[yangqiang@localhost config]$ mysql -u root
\Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update MySQL.user set password=PASSWORD('123456') where User='root';
ERROR 1146 (42S02): Table 'MySQL.user' doesn't exist
mysql> update user set password=PASSWORD('123456') where User='root';
ERROR 1046 (3D000): No database selected
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'rootmysql> UPDATE user SET Password = password ( 'new-passwor' ) WHERE User = 'root'mysql> UPDATE user SET Password = password ( 'new-passwo' ) WHERE User = 'root' mysql> UPDATE user SET Password = password ( 'new-passw' ) WHERE User = 'root' ;mysql> UPDATE user SET Password = password ( 'new-pass' ) WHERE User = 'root' ;
mysql> UPDATE user SET Password = password ( '123456' ) WHERE User = 'root' ;
ERROR 1046 (3D000): No database selected
mysql>
mysql>
mysql>
mysql> \q
Bye
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> USE mysql;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql> Ctrl-C -- exit!
Aborted
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$ su -
Password:
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update MySQL.user set password=PASSWORD('newpassword') where User='root';
mysql> update MySQL.user set password=PASSWORD('newpasswor') where User='root';
mysql> update user set password=PASSWORD('123456') where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@localhost ~]# /etc/init.d/mysqld restart
Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
[root@localhost ~]# vim /etc/m
magic makedev.d/ mime.types motd my.cnf
mailcap man.config mke2fs.conf mtab
mail.rc maven/ modprobe.d/ mtools.conf
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

safe_mysqld --skip-grant-tables & 注释掉该行

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~
~
~
~
~
~
~
~
~
~
"/etc/my.cnf" 12L, 287C written
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# exit
logout
[yangqiang@localhost config]$ service mysqld status
mysqld is stopped
[yangqiang@localhost config]$ service mysqld start
Starting mysqld: [FAILED]
[yangqiang@localhost config]$ sudo service mysqld start 重启数据库
[sudo] password for yangqiang:
Starting mysqld: [ OK ]
[yangqiang@localhost config]$ service mysqld status
mysqld (pid 47510) is running...
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
创建redmine的数据库:
mysql> CREATE DATABASE redmine CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)
创建使用redmine数据库的用户redmine
mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
给该账户授权:
mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>
mysql>
mysql> exit
Bye
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$ bu
build-classpath bundle
build-classpath-directory bundler
build-jar-repository bunzip2
builtin busybox
安装bundle,不需要安装数据库中的development以及test
[yangqiang@localhost config]$ bundle install --without development test
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32.
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.......
Using rake 12.3.0
Fetching i18n 0.7.0
Installing i18n 0.7.0
Fetching minitest 5.11.3

Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::FetchError Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/minitest-5.11.3.gem)Installing minitest 5.11.3
Using thread_safe 0.3.6
……
到该行时报错:
Installing mysql2 0.4.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/yangqiang/.rvm/gems/ruby-2.3.0/gems/mysql2-0.4.10/ext/mysql2
/home/yangqiang/.rvm/rubies/ruby-2.3.0/bin/ruby -r
./siteconf20180304-47566-1m6lx3.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes

Using mysql_config at /usr/bin/mysql_config

checking for mysql.h... no
checking for mysql/mysql.h... no

mysql.h is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum
install mysql-devel', and try again.

extconf.rb failed
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/yangqiang/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysql-config
--without-mysql-config

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/home/yangqiang/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.10/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/home/yangqiang/.rvm/gems/ruby-2.3.0/gems/mysql2-0.4.10 for inspection.
Results logged to
/home/yangqiang/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.10/gem_make.out

An error occurred while installing mysql2 (0.4.10), and Bundler cannot
continue. 报错信息
Make sure that gem install mysql2 -v '0.4.10' succeeds before bundling.

In Gemfile:
mysql2
[yangqiang@localhost config]$ yum install -y mysql-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
You need to be root to perform this command.
安装缺少的mysql-devel包:
[yangqiang@localhost config]$ sudo yum install -y mysql-devel
[sudo] password for yangqiang:
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile

  • base: centos.ustc.edu.cn
  • extras: mirrors.nju.edu.cn
  • updates: mirrors.nju.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql-devel.x86_64 0:5.1.73-8.el6_8 will be installed
    --> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size

Installing:
mysql-devel x86_64 5.1.73-8.el6_8 base 130 k

Transaction Summary

Install 1 Package(s)

Total download size: 130 k
Installed size: 388 k
Downloading Packages:
mysql-devel-5.1.73-8.el6_8.x86_64.rpm | 130 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql-devel-5.1.73-8.el6_8.x86_64 1/1
Verifying : mysql-devel-5.1.73-8.el6_8.x86_64 1/1

Installed:
mysql-devel.x86_64 0:5.1.73-8.el6_8

Complete!
安装缺少的组件:
[yangqiang@localhost config]$ gem install mysql2 -v '0.4.10'
Building native extensions. This could take a while...
Successfully installed mysql2-0.4.10
Parsing documentation for mysql2-0.4.10
Installing ri documentation for mysql2-0.4.10
Done installing documentation for mysql2 after 1 seconds
1 gem installed
再次安装bundle:
[yangqiang@localhost config]$ bundle install --without development test rmagick
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies......
Using rake 12.3.0
Using i18n 0.7.0
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 4.2.8
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.3.0
Using nokogiri 1.8.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.9
Using crass 1.0.3
Using loofah 2.2.0
Using rails-html-sanitizer 1.0.3
Using actionview 4.2.8
Using rack 1.6.9
Using rack-test 0.6.3
Using actionpack 4.2.8
Using globalid 0.4.1
Using activejob 4.2.8
Using mime-types-data 3.2016.0521
Using mime-types 3.1
Using mail 2.6.6
Using actionmailer 4.2.8
Using actionpack-xml_parser 1.0.2
Using activemodel 4.2.8
Using arel 6.0.4
Using activerecord 4.2.8
Using public_suffix 3.0.2
Using addressable 2.5.2
Using bundler 1.16.1
Using coderay 1.1.2
Using concurrent-ruby 1.0.5
Using css_parser 1.6.0
Using htmlentities 4.3.4
Using thor 0.20.0
Using railties 4.2.8
Using jquery-rails 3.1.4
Using mimemagic 0.3.2
Using mysql2 0.4.10
Fetching net-ldap 0.12.1
Installing net-ldap 0.12.1
Fetching protected_attributes 1.1.4
Installing protected_attributes 1.1.4
Fetching ruby-openid 2.3.0
Installing ruby-openid 2.3.0
Fetching rack-openid 1.4.2
Installing rack-openid 1.4.2
Using sprockets 3.7.1
Using sprockets-rails 3.2.1
Fetching rails 4.2.8
Installing rails 4.2.8
Fetching rbpdf-font 1.19.1
Installing rbpdf-font 1.19.1
Fetching rbpdf 1.19.3
Installing rbpdf 1.19.3
Fetching redcarpet 3.4.0
Installing redcarpet 3.4.0 with native extensions
Fetching request_store 1.0.5
Installing request_store 1.0.5
Fetching roadie 3.2.2
Installing roadie 3.2.2
Fetching roadie-rails 1.1.1
Installing roadie-rails 1.1.1
Bundle complete! 31 Gemfile dependencies, 54 gems now installed.
Gems in the groups development, test and rmagick were not installed.
Use bundle info [gemname] to see where a bundled gem is installed.
安全设置:设置rails加密存储会话数据的cookies,阻止tampering***
[yangqiang@localhost config]$ bundle exec rake generate_secret_token
(in /usr/local/redmine)
[yangqiang@localhost config]$ RAILS_ENV=production bundle exec rake db:migrate
(in /usr/local/redmine)
== 1 Setup: migrating =========================================================
-- create_table("attachments", {:force=>true})
-> 0.0128s
……
== 20170419144536 AddViewMessagesToAllExistingRoles: migrating ================
== 20170419144536 AddViewMessagesToAllExistingRoles: migrated (0.0251s) =======
设置数据库结构:
[yangqiang@localhost config]$ RAILS_ENV=production bundle exec rake db:migrate
(in /usr/local/redmine)
数据库缺省设置:
[yangqiang@localhost config]$ RAILS_ENV=production bundle exec rake redmine:load_default_data
(in /usr/local/redmine)

Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] zn^H
Unknown language!
Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] zh

Default configuration data loaded.
[yangqiang@localhost config]$ service iptables status
iptables: Only usable by root. [WARNING]
[yangqiang@localhost config]$ sudo service iptables status
[sudo] password for yangqiang:
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

[yangqiang@localhost config]$ sudo service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$
[yangqiang@localhost config]$ ruby
additional_environment.rb.example environment.rb
application.rb environments/
boot.rb initializers/
configuration.yml.example locales/
database.yml routes.rb
database.yml.example settings.yml
[yangqiang@localhost config]$ ruby
additional_environment.rb.example environment.rb
application.rb environments/
boot.rb initializers/
configuration.yml.example locales/
database.yml routes.rb
database.yml.example settings.yml
[yangqiang@localhost config]$ ruby script/server webrick -e production
ruby: No such file or directory -- script/server (LoadError)
开启redmine:
[yangqiang@localhost config]$ bundle exec rails server webrick -e production
=> Booting WEBrick
=> Rails 4.2.8 application starting in production on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
[2018-03-04 20:11:24] INFO WEBrick 1.3.1
[2018-03-04 20:11:24] INFO ruby 2.3.0 (2015-12-25) [x86_64-linux]
[2018-03-04 20:11:24] INFO WEBrick::HTTPServer#start: pid=49044 port=3000

注意开启的时候必须位于/usr/local/redmine/config目录:
[yangqiang@localhost ~]$ bundle exec rails server webrick -e production
Could not locate Gemfile or .bundle/ directory

[yangqiang@localhost ~]$ sudo netstat -tnlp | grep ruby
[sudo] password for yangqiang:
tcp 0 0 127.0.0.1:3000 0.0.0.0: LISTEN 49175/ruby
tcp 0 0 ::1:3000 :::
LISTEN 49175/ruby
[yangqiang@localhost ~]$
默认情况下只有localhost:3000可以访问,需要修改/etc/hosts文件,使localhost可以映射到本地IP地址上来:
[yangqiang@localhost ~]$ sudo vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.110.128 localhost
~
~
~

[yangqiang@localhost ~]$
[yangqiang@localhost ~]$
重启服务:
[yangqiang@localhost ~]$ sudo netstat -tnlp | grep ruby
tcp 0 0 192.168.110.128:3000 0.0.0.0: LISTEN 49291/ruby
tcp 0 0 127.0.0.1:3000 0.0.0.0:
LISTEN 49291/ruby
tcp 0 0 ::1:3000 :::* LISTEN 49291/ruby
[yangqiang@localhost ~]$

访问:http://192.168.110.128:3000

后台运行该服务:
[redmine@localhost config]$ nohup bundle exec rails server webrick -e production &
[1] 14387
[redmine@localhost config]$ nohup: ignoring input and appending output to `nohup.out'

参考资料:
http://www.rvm.io/
https://ruby-china.org/wiki/install_ruby_guide/
http://www.redmine.org/projects/redmine/wiki/RedmineInstall
http://www.redmine.org.cn/334.html
http://www.redmine.org/projects/redmine/wiki/Download

常见错误:

  1. 报错信息:
    [root@main1 config]# bundle install --without development test
    Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your
    bundle as root will break this application for all non-root users on this machine.

[!] There was an error parsing Gemfile: undefined method `[]' for nil:NilClass. Bundler cannot continue.

from /usr/local/redmine/Gemfile:64

-------------------------------------------

database_config = YAML::load(ERB.new(IO.read(database_file)).result)

adapters = database_config.values.map {|c| c['adapter']}.compact.uniq

if adapters.any?

-------------------------------------------

原因:数据库中production 字段需要顶格,否则找不到相应的adapter。

完整操作过程:

邮箱功能配置:
修改:configuration.yml,注意不要使用TAB键,以两个空格作为行的区分,注意格式。
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "smtp.163.com"
port: 25
authentication: :plain
domain: '163.com'
user_name: 'xxxxx@163.com'
password: 'xxxxx'
其他条件:

  1. 服务器安装sendmail软件;
  2. 163邮箱开启SMTP服务,并且设置客户端验证密码。
    重启服务,进入到设置进行邮箱相关的配置以及测试。

转载于:https://blog.51cto.com/9652359/2107747

 类似资料: