Update the System
Copy and execute the following command to update the critical components of the system :1
yum update
After the update completed, we need to restart the system using the following command :1
reboot
Install the dependencies packages
These are the basic software packages for environment settings and utility tools to compile other packages in the next section.
Copy the block command and execute in the Putty Windows :
This is a long command line, copy all and implementation.1
yum -y install nano zip unzip libyaml-devel zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel
Install Apache and MySQL
Apache is a server application for communicating over the HTTP protocol. Apache runs on operating systems such as Unix, Linux, Microsoft Windows, and other operating systems.
Apache play an important role in the development of the internet and the world wide web.
MySQL is the database management free open source most popular on the world, MySQL has high speed, stability and ease of use, portability, operating on multiple operating systems offer a large system is very powerful utility functions.
With the speed and high security, MySQL is well suited for applications that access databases on the internet.
Use the following command to install :1
yum -y install httpd mysql mysql-server
Allow start services when OS boot :1
2
3
4chkconfig httpd on
chkconfig mysqld on
service httpd start
service mysqld start
Set the password for MySQL1
/usr/bin/mysql_secure_installation
Because we not have a password for the root account so you press Enter to skip.1
Enter current password for root (enter for none):
Select Yes to set the password for the MySQL root account.1
Set root password? [Y/n] Y
Enter and confirm your password, remove the anonymous user, select Yes1
Remove anonymous users? [Y/n] Y
Allow remote login to MySQL as root account, select No.1
Disallow root login remotely? [Y/n] n
Delete the test database, select Yes1
Remove test database and access to it? [Y/n] Y
Reload privilege tables, select Yes1
Reload privilege tables now? [Y/n] Y
Turn off SELinux
SELinux is a security feature advanced for Linux operating system, when installing the system you need to turn off this feature to get the process done smoothly, after successful you can turn on back if you want.1
nano /etc/selinux/config
Change the file content :1
SELINUX=disabled
Press CTRL + O to save the file and press CTRL + X to exit.
Set up the Hostname
By default when installing a new OS Centos not set the hostname, so we need to setting with the command :1
nano /etc/hosts
1 | 127.0.0.1 localhost |
Add your domain name or host name that you set on both the command line, save the file and exit, the server name will be changed when restarting.
Configuring the Firewall
We do not want to turn off the firewall because it’s quite important, so you need to add rules to allow port 80 for HTTP and port 443 for HTTPS.
In the Centos OS, you can configuration firewall by editing files iptables and ip6tables.1
nano /etc/sysconfig/iptables
1 | # Firewall configuration written by system-config-firewall |
Press Enter to create a new line after the line of port 22, copy the following two commands and right click on the window to the Paste command.1
2-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
Press CTRL + O to save the file and press CTRL + X to exit.
The same applies for IP6 firewall :1
nano /etc/sysconfig/ip6tables
Add these lines to the file.1
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
After you finish editing both files, run the commands to apply the new rules for firewall.1
2/etc/init.d/iptables restart
/etc/init.d/ip6tables restart
Allow turn on the firewall when reboot the operating system.1
2chkconfig iptables on
chkconfig ip6tables on
Finally, we need to restart the system to apply the changes to the SELinux and Hostname.1
reboot
Install PHP and phpMyAdmin
Because we use MySQL database management system, so we need to install phpMyAdmin program management.
phpMyAdmin is a free open source tool written by PHP language to manage MySQL database via a web browser.
It can create, modify or delete databases, tables, fields or records, perform SQL statements, or managing users and permissions.
The command to install PHP and the packages :1
yum -y 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
Restarting the Apache service :1
service httpd restart
And install phpMyadmin :1
2
3rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum -y install phpmyadmin
Editing the virtual host file to allow remote login to the phpMyadmin.1
2
3
4
5
6
7
8
9
10
11
12
13
14 GNU nano 2.0.9 File: /etc/httpd/conf.d/phpmyadmin.conf
#
# Web application to manage MySQL
#
<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
Replace text “Allow from 127.0.0.1” to “Allow from all”, save the file and exit.
Editing the configuration file for the phpMyadmin1
nano /usr/share/phpmyadmin/config.inc.php
Replace text :1
$cfg['Servers'][$i]['auth_type'] = 'cookie';
To:1
$cfg['Servers'][$i]['auth_type'] = 'http';
Save the file and exit, restarting the Apache service :1
service httpd restart
After successfully installed phpMyadmin, you can check at the address :
http://your-domain/phpmyadmin
Login with account : root / your_password
With Password has been set at step install MySQL database in the above.
Note: If you install the Redmine system on the PC or in a virtual machine which not on the dedicated server, we need to switch the application phpMyadmin to run on port 8080 because port 80 will be used for Redmine in the next steps.
We need add a port 8080 to the firewall and change the VirtualHost for phpMyadmin.1
nano /etc/sysconfig/iptables
1 | # Firewall configuration written by system-config-firewall |
Add the command line :1
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
The same applies for IP6 firewall :1
nano /etc/sysconfig/ip6tables
Add the command line :1
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
Restarting firewall service to allow the new port.1
2/etc/init.d/iptables restart
/etc/init.d/ip6tables restart
Editing the VirtualHost file to run phpMyadmin on the port 80801
nano /etc/httpd/conf.d/phpmyadmin.conf
change1
2
3
4
5
6
7
8
9
10
11#
# Web application to manage MySQL
#
<Directory "/usr/share/phpmyadmin">
Order Deny,Allow
Deny from all
Allow from all
</Directory>
Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin
to:1
2
3
4<VirtualHost *:8080>
DocumentRoot /usr/share/phpmyadmin/
ServerName your_domain.com
</VirtualHost>
Next, add the command to allows listening on the port 8080 in the file “httpd.conf”1
nano /etc/httpd/conf/httpd.conf
Add the command line :1
Listen 8080
Save the file and exit, restarting the Apache service :1
service httpd restart
Now, phpMyadmin will run on the port 8080 at the address :
Install Ruby
Ruby is a object-oriented programming language, capable of reflection. Syntax inherited from Ada and Perl with object-oriented features of Smalltalk, and also share some features with Python, Lisp, Dylan and CLU, Ruby is a single phase interpreter.
Ruby provides programming patterns, including functional programming, object-oriented, imperative, reflective, it uses dynamic variable and automatic memory management.
Install Ruby interpreter with version management program RVM.1
\curl -L https://get.rvm.io | bash
After successful, we will launch RVM1
source /etc/profile.d/rvm.sh
The following command will list the versions of Ruby to install :1
rvm list known
1 | [root@iZ23lttzrggZ /]# source /etc/profile.d/rvm.sh |
We choose the stable version [ruby-] 1.9.3 [-p551], and execute the following command :1
rvm install 1.9.3
1 | ruby-1.9.3-p551 - #extracting rubygems-2.4.5.... |
The installation process is pretty long time, but you do not need any intervention, after successful, you check with the following command :1
ruby -v
1 | [root@iZ23lttzrggZ /]# ruby -v |
Install Rubygems
Rubygems is a Ruby’s packages management program, very popular in applications written by Ruby language and the Ruby On Rails framework.1
yum -y install rubygems
1 | [root@iZ23lttzrggZ /]# yum -y install rubygems |
Install Passenger
The full name of the Passenger is Phusion Passenger, known as mod_rails or mod_rack, it is a web application intergrate with Apache and it can operate as a standalone web server support for the Ruby On Rails applications.
Execute the following command :1
gem install passenger
1 | [root@iZ23lttzrggZ /]# gem install passenger |
After last command. Execute the following command :1
passenger-install-apache2-module
执行过程:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49--------------------------------------------
Almost there!
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.55/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.55
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!
Press ENTER to continue.
--------------------------------------------
Deploying a web application: an example
Suppose you have a web application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
</VirtualHost>
And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:
/usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.55/doc/Users guide Apache.html
https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com
Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
[root@iZ23lttzrggZ /]#
After completed, we copy a notification block in the window to create the configuration file in the next steps (select block notification and press C to copy).1
2
3
4
5LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.55/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-4.0.55
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
Create a new virtual host file for Passenger :1
nano /etc/httpd/conf.d/passenger.conf
Paste the command blocks into the empty file and save it, then restart the Apache service.1
service httpd restart
Success!!!!!1
2
3
4[root@iZ23lttzrggZ /]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@iZ23lttzrggZ /]#
Create Database for Redmine
Use MySQLAdmin to create an empty database for Redmine, saved password to fill in the configuration file in the next steps.1
2
3
4
5mysql --user=root --password=root_password_mysql
create database redmine_db character set utf8;
create user 'redmine_admin'@'localhost' identified by 'your_new_password';
grant all privileges on redmine_db.* to 'redmine_admin'@'localhost';
quit;
1 | [root@iZ23lttzrggZ /]# mysql --user=root --password=root_password_mysql |
Install Redmine
Redmine is a main program of the project management system, we will download and install the program from the website of Redmine.
Download Redmine version 2.5.x to directory “/var/www” on the Centos OS.1
2cd /var/www
wget http://www.redmine.org/releases/redmine-2.5.0.tar.gz
Extract the folder and rename directory1
2
3tar xvfz redmine-2.5.0.tar.gz
mv redmine-2.5.0 redmine
rm -rf redmine-2.5.0.tar.gz
Configuring the Database
The next, we need to configure the database was created from the above steps.1
2
3cd /var/www/redmine/config
cp database.yml.example database.yml
nano database.yml
database.yml infomations:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
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
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
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
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
database: redmine_test
host: localhost
username: root
password: ""
encoding: utf8
# PostgreSQL configuration example
#production:
# adapter: postgresql
# database: redmine
# host: localhost
# username: postgres
# password: "postgres"
# SQLite3 configuration example
#production:
# adapter: sqlite3
# database: db/redmine.sqlite3
# SQL Server configuration example
#production:
# adapter: sqlserver
# database: redmine
# host: localhost
# username: jenkins
# password: jenkins
Enter name for database, enter username and password of the database.
Change this:1
2
3
4
5
6
7production:
adapter: mysql2
database: redmine
host: localhost
username: root
password: ""
encoding: utf8
To:1
2
3
4
5
6
7production:
adapter: mysql2
database: redmine_db
host: localhost
username: redmine_admin
password: "LmmBao@2014"
encoding: utf8
Press CTRL + O to save the file and CTRL + X to exit.
Setting up Rails
Install the package library support for Rails using the Bundle.1
2
3
4cd /var/www/redmine
gem install bundler
bundle install
rake generate_secret_token
1 | [root@iZ23lttzrggZ config]# cd /var/www/redmine |
*When i run bundle install command, an error occurred while installing rmagick (2.13.4), and Bundler cannot continue.1
2
3
4
5Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p551/gems/rmagick-2.13.4 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/rmagick-2.13.4/gem_make.out
An error occurred while installing rmagick (2.13.4), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.4'` succeeds before bundling.
[root@iZ23lttzrggZ redmine]# yum install ImageMagick-devel
Get solution fromStack Overflow
Then run bundle install again.
Success!!1
2
3
4
5
6
7
8
9
10
11
12
13Installing rmagick 2.13.4
Installing rubyzip 1.1.6
Installing websocket 1.2.1
Installing selenium-webdriver 2.44.0
Installing shoulda-context 1.0.2
Installing shoulda-matchers 1.4.1
Installing shoulda 3.3.2
Installing yard 0.8.7.6
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rmagick:
Please report any bugs. See https://github.com/gemhome/rmagick/compare/RMagick_2-13-2...master and https://github.com/rmagick/rmagick/issues/18
[root@iZ23lttzrggZ redmine]#
The next, we create the database table for the Redmine application.1
2RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
1 | [root@iZ23lttzrggZ redmine]# RAILS_ENV=production rake redmine:load_default_data |
Activate FCGI
1 | cd /var/www/redmine/public |
Setting up Apache and FastCGI
1 | cd /var/www/ |
Creating Files Directory
This directory contains data files generated during the operation of Redmine as document or image file, we create a new directory in the “/opt”.1
2
3
4
5mkdir -p /opt/redmine/files
chown -R apache:apache /opt/redmine
cd /var/www/redmine/config
cp configuration.yml.example configuration.yml
nano configuration.yml
1 | 94 # Absolute path to the directory where attachments are stored. |
Enter the directory path containing the data files you just created in the previous step into the line “attachments_storage_path”.
Note: You must add a space at the begin of the path “/opt/redmine/files” after character “:”1
2
3
4
5
6
7
8 94 # Absolute path to the directory where attachments are stored.
95 # The default is the 'files' directory in your Redmine instance.
96 # Your Redmine instance needs to have write permission on this
97 # directory.
98 # Examples:
99 # attachments_storage_path: /var/redmine/files
100 # attachments_storage_path: D:/redmine/files
101 attachments_storage_path: /opt/redmine/files
Configuring Email
Another very important function of Redmine is using email to notify members when the contents of each project changes, Redmine can use many different methods to send email that is Sendmail, SMTP, GMail …
To configure the email we will edit the configuration file.1
nano /var/www/redmine/config/configuration.yml
The simplest is you use features of the default SendMail in the Centos OS by settings :1
2email_delivery:
delivery_method: :sendmail
Note : Do not use the Tab key to indent when editing the configuration file, you need to use the space bar on the keyboard.
If you use GMail’s SMTP, you need to register an email account with the login methods used password normal and disable two-step authentication by smart phone.
Enter your Gmail account as below :1
2
3
4
5
6
7
8
9
10email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "smtp.gmail.com"
port: 587
domain: "smtp.gmail.com"
authentication: :plain
user_name: "your_email@gmail.com"
password: "your_password"
Save the file configuration and exit.
Create Virtual Host for Redmine
Create an Apache configuration file for the Redmine application at the port 80.1
nano /etc/httpd/conf.d/redmine.conf
Copy the text below and paste into the editor window, note the information to change your domain name.
1 | <VirtualHost *:80> |
Save the file configuration and exit.
Running Redmine
Before execute Redmine in the first time, we must permission for the directory installed Redmine and restart Apache service.1
2
3
4cd /var/www
chown -R apache:apache redmine
chmod -R 755 redmine
service httpd restart
Redmine will run at the following address URL :
http://your-domain
Login to system with an administrator account : admin / admin
You can change your password after successful login.
We can see Redmine has running but very primitive, in the next steps we will install the support plugins and customized Redmine to use professional.
Install Subversion
Subversion, also known as SVN, it is a version management system is very popular and easy to use, most programmers can use it competently.
We need to create a folder to store data for Redmine, the following command creates a directory and permissions for the Apache service.1
2
3mkdir -p /opt/repositories/svn
chown -R apache:apache /opt/repositories/
chmod 0755 /opt/repositories
The following command install Subversion and the packages :1
yum install mod_dav_svn subversion subversion-ruby
1 | [root@iZ23lttzrggZ /]# yum install mod_dav_svn subversion subversion-ruby |
The next, we will create a directory and copy the file called “Redmine.pm”, it responsible for interface data repository with Redmine and it is written by Perl language programming.1
2mkdir /usr/lib64/perl5/vendor_perl/Apache
ln -s /var/www/redmine/extra/svn/Redmine.pm /usr/lib64/perl5/vendor_perl/Apache/Redmine.pm
Note : If you are using 32 bit Centos, change the path “/usr/lib64” to “/usr/lib”
After installation is complete, from the Redmine application, go to the page Administration> Settings> Repositories to check the results.
To support the authentication and access to data repository for each member, we need to create a virtual host for the Apache service can access Redmine database.1
nano /etc/httpd/conf.d/subversion.conf
Add the following lines to the end and still retain the old contents of the file :1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19PerlLoadModule Apache::Redmine
<Location /svn>
DAV svn
SVNParentPath "/opt/repositories/svn"
SVNListParentPath on
Order deny,allow
Deny from all
Satisfy any
LimitXMLRequestBody 0
SVNPathAuthz off
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
AuthType Basic
AuthName "Subversion Repository"
Require valid-user
RedmineDSN "DBI:mysql:database=redmine_db;host=localhost:3306"
RedmineDbUser "redmine_admin"
RedmineDbPass "your_password_database_redmine"
</Location>
Note : You need to change the password in the “RedmineDbPass” to correct the database password of Redmine.
At this point, we have finished the basic settings for Redmine.
Thank you!