Saturday 1 June 2013

Installation of OTRS 3.2.7 on CentOS 6.4 using PostgreSQL as database



To share my experience on instillation, configuration, troubleshooting, monitoring and other basic things related to server I started blogging . Steps followed to install OTRS 3.2.7 on Centos 6.4 using PostgreSQL as database given below.



First I check minimum prerequisites to start installation. below given prerequisites are minimum to complete installation of OTRS 3.27 on Centos 6.4

Minimum prerequisites
A basic install of CentOS 6.4 with these settings:
CentOS SELinux is set to permissive.
CentOS firewall must have HTTP as trusted.
OTRS requires a properly configured & running Apache webserver & backend database. The basic install of CentOS 6.4 included an Apache install with no database. Steps are provided below to do a basic configuration of Apache & MySQL (my current database of choice).
System will need a working Internet connection.

Note: I disabled Firewall and Selinux.

Apache

We are using Apache for OTRS so we will start from installation of Apache server.


To check http packages in any repository enabled on your system or installed use below given command
  # yum list httpd
To install httpd packages we will run below given command:
 # yum install httpd

 Now we will enable httpd on run levels 2,3 and 5:

 # chkconfig --levels 235 httpd on 

To verify run levels enabled for httpd:
 # chkconfig --list httpd 

Basic Apache config 

Make backup of httpd.conf file then after that we will make basic configuration of httpd.
# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.back

Edit httpd.conf file using vi editor:
# vi /etc/httpd/conf/httpd.conf
At minimum update ServerAdmin, ServerName and port number of httpd:

ServerAdmin hits@yourdomain.com
ServerName [hostname or IP address]:80
Listen yourIP:80

After basic configuration done we will start httpd:
 # service httpd start


 OTRS
 
These steps were done using OTRS version 3.2.7. Ensure that you get the latest version  and download the latest OTRS 3.x.x for RHEL 6 / CentOS 6 RPM. I am using otrs-3.2.7-01.noarch.rpm in this post for installation.

To resolve dependencies  I run:
 # rpm -qpR otrs-3.2.7-01.noarch.rpm
perl
perl-core
cronie
perl(DBI)
perl(Crypt::SSLeay)
perl(Digest::SHA)
perl(Net::LDAP)
perl(URI)
mod_perl
httpd
procmail
perl(Date::Format)
perl(LWP::UserAgent)
perl(Net::DNS)
perl(IO::Socket::SSL)
perl(XML::Parser)
/bin/sh
/bin/sh

# rpm -ivh otrs-3.2.7-01.noarch.rpm
error: Failed dependencies:
        perl-core is needed by otrs-3.2.7-01.noarch
        perl(Crypt::SSLeay) is needed by otrs-3.2.7-01.noarch
        perl(Digest::SHA) is needed by otrs-3.2.7-01.noarch
        perl(Net::LDAP) is needed by otrs-3.2.7-01.noarch
        perl(URI) is needed by otrs-3.2.7-01.noarch
        mod_perl is needed by otrs-3.2.7-01.noarch
        procmail is needed by otrs-3.2.7-01.noarch
        perl(Date::Format) is needed by otrs-3.2.7-01.noarch
        perl(LWP::UserAgent) is needed by otrs-3.2.7-01.noarch
        perl(Net::DNS) is needed by otrs-3.2.7-01.noarch
        perl(IO::Socket::SSL) is needed by otrs-3.2.7-01.noarch
        perl(XML::Parser) is needed by otrs-3.2.7-01.noarch

rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsBzip2) <= 3.0.5-1




Now I know which dependencies to install.
To resolve all perl-URI dependency:

# yum install perl-core 'perl(Crypt::SSLeay)' 'perl(Digest::SHA)' 'perl(Net::LDAP)' 'perl(URI)' 'mod_perl' 'perl(Date::Format)' 'perl(LWP::UserAgent)' 'perl(Net::DNS)' 'perl(IO::Socket::SSL)' 'perl(XML::Parser)' 'perl-DBD-Pg' procmail -y 


Install OTRS RPM using yum:

# yum --nogpgcheck install otrs-3.2.7-01.noarch.rpm -y


Now let’s Install PostgreSQL

Download the pgdg-centos92-9.2-6.noarch.rpm rpm from PostgreSQL rpm repository
Now install it using this command.
# rpm -ivh pgdg-centos92-9.2-6.noarch.rpm
Now we have installed the pgdg central PostgreSQL repo, we should have postgresql rpms show up in yum package manager search. Run the following command on command line to search for all postgres related available rpms.
#yum search postgres
To install PostgreSQL client / Server programs run the following command

#yum install postgresql92 postgresql92-server
After successful installation of PostgreSQL database server / client on this CentOS Server.
We will create default data/tables into this newly build database server by running command:

#service postgresql-9.2 initdb

 now start the PostgreSQL database
server by running following command:
#service postgresql-9.2 start

To make your database server auto starts when this CentOS server starts/restarts run below given command:

#chkconfig postgresql-9.2 on


Now login into database as postgres user,

# su – postgres

$psql -dpostgres
Now you are inside PostgreSQL database server, so create a user for the database:
postgres=# CREATE role otrs LOGIN PASSWORD 'otrs' SUPERUSER;
CREATE ROLE

Create OTRS database:
postgres=#CREATE DATABASE otrs ENCODING 'utf8' OWNER otrs;


postgres=#\q

$ cd /opt/otrs/

Create the OTRS tables:
$ psql otrs < scripts/database/otrs-schema.postgresql_before_8_2.sql
Insert initial data:
$ psql otrs < scripts/database/otrs-initial_insert.postgresql_before_8_2.sql
Create foreign keys to other tables:
$ psql otrs < scripts/database/otrs-schema-post.postgresql_before_8_2.sql

$exit

OTRS Database Driver Configuration:
===================================

Now add the correct database credentials to OTRS. Edit this section in your configuration file /opt/otrs/Kernel/Config.pm
# vim /opt/otrs/Kernel/Config.pm


=================
   $Self->{DatabaseHost} = 'localhost';

    # The database name
    $Self->{Database} = 'otrs';

    # The database user
    $Self->{DatabaseUser} = 'otrs';

    # The password of database user. You also can use bin/otrs.CryptPassword.pl
    # for crypted passwords
    $Self->{DatabasePw} = 'otrs';

We are using PostgreSQL so we  should remove the comment (#) before this line:
    #    $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};host=$Self->{DatabaseHost};";

We installed PostgresSQL 9.2 hence, activate the legacy driver by uncommenting this line:

    #    $Self->{DatabasePostgresqlBefore82} = 1;
===============================================
Make the changes in your database configuration file :
Uncomment the line #listen_addresses = ‘localhost’ and change it to listen_addresses = ‘*’
#vim /var/lib/pgsql/9.2/data/postgresql.conf
================================================
listen_addresses = '*' 
================================================
The second configuration file that you need to edit in order to grant access to outside world is below [Host based authentication file]:
Add a new line under IPv4 local connections all the way to the near bottom of the file. Make appropriate changes to network you want this new user to login from. If your subnet is 192.168.1.1/24 or 192.168.1.1/32, please use that or what ever is relevant in you case. This rule I added indicates the database server to accept connections for this user originating with in 172.24.8.0/21 sub-net network.
# vim /var/lib/pgsql/9.2/data/pg_hba.conf
===============================================
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             172.24.8.0/21            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

=================================================




Now restart postgres server to get these changes in effect
# service postgresql-9.2 restart
Now run /opt/otrs/bin/otrs.CheckDB.pl to see if the connection
is successful. If this is working, you can log in to OTRS using the web frontend.

/opt/otrs/bin/otrs.CheckDB.pl


Let’s start otrs…
# service otrs start

 The first login…
open http://localhost/otrs/index.pl and login with user “root@localhost”, password “root” 

If on same machine as OTRS install you point your browser to http://localhost/otrs/index.pl otherwise replace localhost with domain name or IP address.  




1 comment:

  1. Nice listing, thanks.
    Quick note: the pg_hba.conf can make a BIG difference - any 'authentication failed ...' messages are usually traced back to this file.
    'local all all trust' while a big hole is good for testing purposes.

    ReplyDelete