We are dealing with many different software components, and along with them, their dependencies. Installing Ruby requires a C compiler and HTTPD development modules are required for other components.
System Pre-requisites
These are the external packages available as RPMs in the default CentOS repositories.
# Install the various dependencies available through yum
sudo yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel ftp wget ImageMagick-devel
# For passenger, which is itself another dependency, you'll need the C++ Compiler
sudo yum install gcc-c++
# Download and add the MySQL repository
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
# Update everything
sudo yum update
Install Ruby
First, download ruby from the most reliable of sources (or download it on a separate machine and FTP it into your machine).
# Create your own Downloads folder
mkdir ~/Downloads
cd ~/Downloads
# Download the Ruby source files
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
# Un-tar-gz the archive
tar -zxvf ./ruby-2.3.1.tar.gz
Next, install Ruby.
# Building it from source code
cd ruby-2.3.1
./configure
sudo make
# Install Ruby
sudo make install
# Check if installed
ruby -v
which ruby
Install RubyGems
To determine what is the latest version of RubyGems go to the RubyGems Download Page. There, you can get the link to the TGZ (or download it to FTP into your machine).
# Switch to root (enter your own root password)
su root
Password: **********
# Download the latest version of RubyGems
mkdir ~/Downloads
cd ~/Downloads
wget https://rubygems.org/rubygems/rubygems-2.6.6.tgz
# Un-tar-gz the archive
tar -zxvf ./rubygems-2.6.6.tgz
Next, install RubyGems.
# Install using Ruby
cd rubygems-2.6.6
ruby setup.rb
# Check if installed
gem -v
which gem
# Exit root (if you haven't already)
exit
Install Passenger
Move the original folder apache conf.d
mv /etc/httpd/conf.d /etc/httpd/conf.d-original
Create a new folder and virtual host file for Passenger :
mkdir /etc/httpd/conf.d
vi /etc/httpd/conf.d/passenger.conf
For This Installation
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).
LoadModule passenger_module /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.1/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.1
PassengerDefaultRuby /usr/local/bin/ruby
Paste the command blocks into the empty file and save it, then restart the Apache service.
service httpd restart
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 commands :
gem install passenger
passenger-install-apache2-module
For New Installation
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).
LoadModule passenger_module /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.1/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.1.1
PassengerDefaultRuby /usr/local/bin/ruby
Paste the command blocks into the empty file and save it, then restart the Apache service.
service httpd restart
Install MySQL Server
MySQL Server repository for CentOS is not included in the default installation. You will need to download and add it. Refer to the prerequisites in a previous section. Assuming the repository is included, run the following:
# Install MySQL Server
sudo yum install mysql-server
# Verify that it is running
sudo chkconfig mysqld on
sudo systemctl start mysqld
# Configure root password. Note that initial password is blank, just hit
/usr/bin/mysql_secure_installation
Next, create a Redmine database and account.
# Access MySQL as root
mysql -uroot -p
Enter password: **********
# Create Redmine database
mysql> create database redmine character set utf8;
# Create associated redmine account
mysql> create user 'redmine'@'localhost' identified by 'my_password';
mysql> grant all privileges on redmine.* to 'redmine'@'localhost';
mysql> flush privileges;
mysql> exit;
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 the latest version of Redmine
cd ~/Downloads
wget http://www.redmine.org/releases/redmine-3.3.0.tar.gz
# Un-tar-gz the archive
tar -zxvf redmine-3.3.0.tar.gz
# Move it to an appropriate location
sudo mv ./redmine-3.3.0 /var/www/redmine
Configuring the Database
The next, we need to configure the database was created from the above steps.
cd /var/www/redmine/config
cp database.yml.example database.yml
vi database.yml
All lines in the file should be commented out except for the following, with the appropriate entries for password and database credentials configured in a previous section.
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "********"
encoding: utf8
Setting up Rails
Install the package library support for Rails using the Bundle.
cd /var/www/redmine
gem install bundler
bundle install
rake generate_secret_token
If got error
/usr/local/lib/ruby/gems/2.3.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: key "inodot" is duplicated and overwritten on line 466
vi /usr/local/lib/ruby/gems/2.3.0/gems/htmlentities-4.
3.1/lib/htmlentities/mappings/expanded.rb
Search the duplicate key "inodot" on line 466
#
# This table added by Philip (flip) Kromer
# using the mapping by John Cowan
# ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/SGML.TXT
#
# The following table maps SGML character entities from various
# public sets (namely, ISOamsa, ISOamsb, ISOamsc, ISOamsn, ISOamso,
# ISOamsr, ISObox, ISOcyr1, ISOcyr2, ISOdia, ISOgrk1, ISOgrk2,
# ISOgrk3, ISOgrk4, ISOlat1, ISOlat2, ISOnum, ISOpub, ISOtech,
# HTMLspecial, HTMLsymbol) to corresponding Unicode characters.
#
# The table has five tab-separated fields:
# :bare => SGML character entity name
# :hex => Unicode 2.0 character code
# :entity => SGML character entity
# :type => SGML public entity set
# :udesc => Unicode 2.0 character name (UPPER CASE)
#
# Entries which don't have Unicode equivalents have "0x????" for
# :hex and a lower case :udesc (from the public entity set DTD).
#?ino
search hit TOP, continuing at BOTTOM'ijlig'=> 0x0133, # LATIN SMALL LIGATURE IJ
'Imacr'=> 0x012a, # LATIN CAPITAL LETTER I WIITH MACRON
'imacr'=> 0x012b, # LATIN SMALL LETTER I WITHH MACRON
'image'=> 0x2111, # xhtml BLACK-LETTER CAPITAL I
'incare'=> 0x2105, # CARE OF
'infin'=> 0x221e, # xhtml INFINITY
'inodot'=> 0x0131, # dupLATIN SMALL LETTER DOTLESSS I
'inodot'=> 0x0131, # dupLATIN SMALL LETTER DOTLESSS I <---- delete="" line="" p="" this=""> 'int'=> 0x222b, # xhtml INTEGRAL
'intcal'=> 0x22ba, # INTERCALATE
'IOcy'=> 0x0401, # CYRILLIC CAPITAL LETTER IIO
'iocy'=> 0x0451, # CYRILLIC SMALL LETTER IO
'Iodot'=> 0x0130, # LATIN CAPITAL LETTER I WIITH DOT ABOVE
'Iogon'=> 0x012e, # LATIN CAPITAL LETTER I WIITH OGONEK
'iogon'=> 0x012f, # LATIN SMALL LETTER I WITHH OGONEK
The next, we create the database table for the Redmine application.
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data
Activate FCGI
cd /var/www/redmine/public
mkdir plugin_assets
cp dispatch.fcgi.example dispatch.fcgi
cp htaccess.fcgi.example .htaccess
Setting up Apache and FastCGI
cd /var/www/
rpm --import https://fedoraproject.org/static/0608B895.txt
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum -y install mod_fcgid
rm -rf epel-release-6-8.noarch.rpm
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".
mkdir -p /opt/redmine/files
chown -R apache:apache /opt/redmine
cd /var/www/redmine/config
cp configuration.yml.example configuration.yml
vi configuration.yml
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 ":"
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.
nano /var/www/redmine/config/configuration.yml
The simplest is you use features of the default SendMail in the Centos OS by settings :
email_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 :
email_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.
vi /etc/httpd/conf.d/redmine.conf
Copy the text below and paste into the editor window, note the information to change your domain name.
ServerName your_domain
ServerAdmin your_domain@domain.com
DocumentRoot /var/www/redmine/public/
ErrorLog logs/redmine_error_log
Options Indexes ExecCGI FollowSymLinks
Order allow,deny
Allow from all
AllowOverride all
---->
Save the file configuration and exit.
Permissions, permissions, permissions
With CentOS, you get SELinux. Security comes with a cost, and if that cost is some additional lines of code in addition to the usual chmod and chown,
that's not too bad, right?
# Allow requests on TCP ports 80 and 443 through
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload
# Change ownership of Redmine folder to Apache
sudo chown -R apache:apache /var/www/redmine
# Change access permissions to Redmine folder
sudo chmod -R 0755 /var/www/redmine
# Enable the serving of files off Apache
sudo chcon -R -t httpd_sys_content_t /var/www/redmine
# Allow httpd to write only to specific folders
sudo chcon -R -t httpd_sys_rw_content_t /var/www/redmine/log
sudo chcon -R -t httpd_sys_rw_content_t /var/www/redmine/tmp/cache
sudo chcon -R -t httpd_sys_rw_content_t /var/www/redmine/files
# Enable sending of emails
sudo setsebool -P httpd_can_network_connect 1
As with all configurations done to Apache and its folders, a restart is necessary.
# Restart Apache once again
sudo systemctl restart httpd
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 :
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
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
systemctl restart httpd.service
phpMyAdmin installation
phpMyAdmin is a web interface through which you can manage your MySQL databases.
phpMyAdmin can now be installed as follows:
yum install phpMyAdmin
Now we configure phpMyAdmin. We change the Apache configuration so that phpMyAdmin allows connections not just from localhost (by commenting out the
We also will configure Virtual Host to run on port 8080 because port 80 is using by Redmine
vi /etc/httpd/conf.d/phpMyAdmin.conf
[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
# Apache 2.4
# Require ip 127.0.0.1
# Require ip ::1
Require all granted
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
[...]
#Add Virtual Host run on port 8080
DocumentRoot /usr/share/phpmyadmin/
ServerName your_domain.com
We also need to add the command to allows listening on the port 8080 in the file "httpd.conf"
vi /etc/httpd/conf/httpd.conf
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
Listen 8080
Next we change the authentication in phpMyAdmin from cookie to http:
vi /etc/phpMyAdmin/config.inc.php
[...]
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?
[...]
# Allow requests on TCP ports 8080 through
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
Restart Apache:
systemctl restart httpd.service
Afterwards, you can access phpMyAdmin under http://192.168.0.100:8080/phpmyadmin/
Install Webmin on CentOS 7
Step 1. First add Webmin official repository.
Webmin isn’t available in the default CentOS repositories, you must add its repository to your system before installing. To do that, run the commands below to create a repository file for Webmin:
vi /etc/yum.repos.d/webmin.repo
And add the following lines:
[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1
We’ll need to install webmin GPG key now, using following command:
wget http://www.webmin.com/jcameron-key.asc
rpm --import jcameron-key.asc
Next step is to update the repositories and all available package updates, to make sure we’re installing the latest version of Webmin. Run following command:
yum check-update
Step 2. Install Webmin.
Install Webmin with the following command:
yum install webmin -y
Start the service and make it start automatically every time you reboot your server:
chkconfig webmin on
service webmin start
By default, Webmin will listen on port 10000. Enable webmin port:
firewall-cmd --permanent --zone=public --add-port=10000/tcp
firewall-cmd --reload
Step 3. Access Webmin.