How to install OTRS (OpenSource Trouble Ticket System) on Ubuntu 16.04

OTRS or Open-source Ticket Request System is an open source ticketing software used for Customer Service, Help Desk, and IT Service Management. The software is written in Perl and javascript. It is a ticketing solution for companies and organizations that have to manage tickets, complaints, support request or other kinds of reports. OTRS supports several database systems including MySQL, PostgreSQL, Oracle and SQL Server it is a multiplatform software that can be installed on Windows and Linux.

In this tutorial, I will show you how to install and configure OTRS on Ubuntu 16.04. I will use PostgreSQL as the database for OTRS, and Apache web server as the web server.

Prerequisites

  • Ubuntu 16.04.
  • Min 2GB of Memory.
  • Root privileges.

Step 1 - Install Apache and PostgreSQL

In this first step, we will install the Apache web server and PostgreSQL. We will use the latest versions from the ubuntu repository.

Login to your Ubuntu server with SSH:

ssh [email protected]

Update Ubuntu repository.

sudo apt-get update

Install Apache2 and a PostgreSQL with the apt:

sudo apt-get install -y apache2 libapache2-mod-perl2 postgresql

Then make sure that Apache and PostgreSQL are running by checking the server port.

netstat -plntu

Install Apache and PostgreSQL

You will see port 80 is used by apache, and port 5432 used by postgresql database.

Step 2 - Install Perl Modules

OTRS is based on Perl, so we need to install some Perl modules that are required by OTRS.

Install perl modules for OTRS with this apt command:

sudo apt-get install -y libapache2-mod-perl2 libdbd-pg-perl libnet-dns-perl libnet-ldap-perl libio-socket-ssl-perl libpdf-api2-perl libsoap-lite-perl libgd-text-perl libgd-graph-perl libapache-dbi-perl libarchive-zip-perl libcrypt-eksblowfish-perl libcrypt-ssleay-perl libencode-hanextra-perl libjson-xs-perl libmail-imapclient-perl libtemplate-perl libtemplate-perl libtext-csv-xs-perl libxml-libxml-perl libxml-libxslt-perl libpdf-api2-simple-perl libyaml-libyaml-perl

When the installation is finished, we need to activate the Perl module for apache, then restart the apache service.

a2enmod perl
systemctl restart apache2

Next, check the apache module is loaded with the command below:

apachectl -M | sort

Enable Apache Perl Module

And you will see perl_module under 'Loaded Modules' section.

Step 3 - Create New User for OTRS

OTRS is a web based application and running under the apache web server. For best security, we need to run it under a normal user, not the root user.

Create a new user named 'otrs' with the useradd command below:

useradd -r -d /opt/otrs -c 'OTRS User' otrs

-r: make the user as a system account.
-d /opt/otrs: define home directory for new user on '/opt/otrs'.
-c: comment.

Next, add the otrs user to 'www-data' group, because apache is running under 'www-data' user and group.

usermod -a -G www-data otrs

Check that the otrs user is available in the '/etc/passwd' file.

grep -rin otrs /etc/passwd

Create new user for OTRS

New user for OTRS is created.

Step 4 - Create and Configure the Database

In this section, we will create a new PostgreSQL database for the OTRS system and make some small changes in PostgreSQL database configuration.

Login to the postgres user and access the PostgreSQL shell.

su - postgres
psql

Create a new role named 'otrs' with the password 'myotrspw' and the nosuperuser option.

create user otrs password 'myotrspw' nosuperuser;

Then create a new database named 'otrs' under the 'otrs' user privileges:

create database otrs owner otrs;
\q

Next, edit the PostgreSQL configuration file for otrs role authentication.

vim /etc/postgresql/9.5/main/pg_hba.conf

Paste the cConfiguration below after line 84:

local   otrs            otrs                                    password
host    otrs            otrs            127.0.0.1/32            password

Save the file and exit vim.

Database Authentication OTRS

Back to the root privileges with "exit" and restart PostgreSQL:

exit
systemctl restart postgresql

PostgreSQL is ready for the OTRS installation.

Configure PostgreSQL for OTRS

Step 5 - Download and Configure OTRS

In this tutorial, we will use the latest OTRS version that is available on the OTRS web site.

Go to the '/opt' directory and download OTRS 5.0 with the wget command:

cd /opt/
wget http://ftp.otrs.org/pub/otrs/otrs-5.0.16.tar.gz

Extract the otrs file, rename the directory and change owner of all otrs files and directories the 'otrs' user.

tar -xzvf otrs-5.0.16.tar.gz
mv otrs-5.0.16 otrs
chown -R otrs:otrs otrs

Next, we need to check the system and make sure it's ready for OTRS installation.

Check system packages for OTRS installation with the otrs script command below:

/opt/otrs/bin/otrs.CheckModules.pl

Make sure all results are ok, it means is our server ready for OTRS.

OTRS Chek Module needed for Installation

OTRS is downloaded, and our server is ready for the OTRS installation.

Next, go to the otrs directory and copy the configuration file.

cd /opt/otrs/
cp Kernel/Config.pm.dist Kernel/Config.pm

Edit 'Config.pm' file with vim:

vim Kernel/Config.pm

Change the database password line 42:

$Self->{DatabasePw} = 'myotrspw';

Comment the MySQL database support line 45:

# $Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";

Uncomment PostgreSQL database support line 49:

$Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};";

Save the file and exit vim.

Then edit apache startup file to enable PostgreSQL support.

vim scripts/apache2-perl-startup.pl

Uncomment line 60 and 61:

# enable this if you use postgresql
use DBD::Pg ();
use Kernel::System::DB::postgresql;

Save the file and exit the editor.

Finally, check for any missing dependency and modules.

perl -cw /opt/otrs/bin/cgi-bin/index.pl
perl -cw /opt/otrs/bin/cgi-bin/customer.pl
perl -cw /opt/otrs/bin/otrs.Console.pl

You should see that the result is 'OK' asshown in the screenshot below:

Check all modules again

Step 6 - Import the Sample Database

In this tutorial, we will use the sample database, it's available in the script directory. So we just need to import all sample databases and the schemes to the existing database created in step 4.

Login to the postgres user and go to the otrs directory.

su - postgres
cd /opt/otrs/

Insert database and table scheme with psql command as otrs user.

psql -U otrs -W -f scripts/database/otrs-schema.postgresql.sql otrs
psql -U otrs -W -f scripts/database/otrs-initial_insert.postgresql.sql otrs
psql -U otrs -W -f scripts/database/otrs-schema-post.postgresql.sql otrs

Type the database password 'myotrspw' when requested.

Import OTRS Sample Database

Step 7 - Start OTRS

Database and OTRS are configured, now we can start OTRS.

Set the permission of otrs file and directory to the www-data user and group.

/opt/otrs/bin/otrs.SetPermissions.pl --otrs-user=www-data --web-group=www-data

Then enable the otrs apache configuration by creating a new symbolic link of the file to the apache virtual host directory.

ln -s /opt/otrs/scripts/apache2-httpd.include.conf /etc/apache2/sites-available/otrs.conf

Enable otrs virtual host and restart apache.

a2ensite otrs
systemctl restart apache2

Make sure apache has no error.

Enable OTRS Apache Virtual Host

Step 8 - Configure OTRS Cronjob

OTRS is installed and now running under apache web server, but we still need to configure the OTRS Cronjob.

Login to the 'otrs' user, then go to the 'var/cron' directory as the otrs user.

su - otrs
cd var/cron/
pwd

Copy all cronjob .dist scripts with the command below:

for foo in *.dist; do cp $foo `basename $foo .dist`; done

Back to the root privilege with exit and then start the cron script as otrs user.

exit
/opt/otrs/bin/Cron.sh start otrs

Enable OTRS Cron

Next, manually create a new cronjob for PostMaster which fetches the emails. I'll configure it tp fetch emails every 2 minutes.

su - otrs
crontab -e

Paste the configuration below:

*/2 * * * *    $HOME/bin/otrs.PostMasterMailbox.pl >> /dev/null

Save and exit.

Now stop otrs daemon and start it again.

bin/otrs.Daemon.pl stop
bin/otrs.Daemon.pl start

Enable OTRS Fetching Email

The OTRS installation and configuration is finished.

Step 9 - Testing OTRS

Open your web browser and type in your server IP address:

http://192.168.33.14/otrs/

Login with default user '[email protected]' and password 'root'.

Installation Successfully OTRS Home Page

You will see a warning about using default root account. Click on that warning message to create new admin root user.

Below the admin page after login with different admin root user, and there is no error message again.

OTRS Admin Dashboard Without Error Messages

If you want to log in as Customer, you can use 'customer.pl'.

http://192.168.33.14/otrs/customer.pl

You will see the customer login page. Type in a customer username and password.

OTRS Customer Login Page

Below is the customer page for creating a new ticket.

Customer Open Ticket

Step 10 - Troubleshooting

If you still have an error like 'OTRS Daemon is not running', you can enable debugging in the OTRS daemon like this.

su - otrs
cd /opt/otrs/

Stop OTRS daemon:

bin/otrs.Daemon.pl stop

And start OTRS daemon with --debug option.

bin/otrs.Daemon.pl start --debug

Reference

Share this page:

16 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: John

After su - otrs

crontab -e

 

touch: cannot touch '/opt/otrs/.selected_editor': Permission denied

 

Should it be done under otrs?

By: SHIJU T PUNNOOSE

Amazing document .. hats off to your for hard work!

By: Marlon

Fantastic How to.

I was able to follow this document to install the latest version (6.0.3) with a modification on "Step 8 - Configure OTRS Cronjob" In order to install the newer version of OTRS, you have to change the syntax for the cronjob:

Original:

*/2 * * * * $HOME/bin/otrs.PostMasterMailbox.pl >> /dev/null

After:

*/2 * * * * $HOME/bin/otrs.PostMaster.pl >> /dev/null

By: Serdjio Ploxa

It's good for me!

By: Serdjio Ploxa

Is good for me !

By: Alexey Gerasimov

Step 8 - Configure OTRS Cronjob (Ubuntu 18.04)

How to fix it? Thanks!!!

$ bin/otrs.Daemon.pl startManage the OTRS daemon process.Daemon started$ ERROR: OTRS-otrs.Daemon.pl - Daemon Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager-10 Perl: 5.26.1 OS: linux Time: Sun May 27 14:52:22 2018 Message: There was an error executing ConfigurationDeploySync: ERROR: OTRS-otrs.Daemon.pl - Daemon Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager-10 Perl: 5.26.1 OS: linux Time: Sun May 27 14:52:22 2018 Message: No deployments found in Database! Traceback (27203):    Module: Kernel::System::SysConfig::ConfigurationDeploySync Line: 3722   Module: (eval) Line: 129   Module: Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager::Run Line: 116   Module: (eval) Line: 316   Module: main::Start Line: 316   Module: bin/otrs.Daemon.pl Line: 137 Traceback (27203):    Module: Kernel::System::Daemon::DaemonModules::BaseTaskWorker::_HandleError Line: 52   Module: Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager::Run Line: 134   Module: (eval) Line: 316   Module: main::Start Line: 316   Module: bin/otrs.Daemon.pl Line: 137

By: phao

 Insert database and table scheme with psql command as otrs user.  (password ................?  )

By: Preetham

Hi, Thanks for this extensive document. Followed this and everything went as mentioned, except that it did not take the default password. Tried a lot but jus tdid not help. Any pointers?

Thanks 

By: Martin

I have the same problem. Can you tell me how can I fix it?

When I start the deamon:

 

Daemon started

$ ERROR: OTRS-otrs.Daemon.pl - Daemon Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager-10 Perl: 5.22.1 OS: linux Time: Sat Feb 23 15:24:11 2019

 

 Message: There was an error executing ConfigurationDeploySync: ERROR: OTRS-otrs.Daemon.pl - Daemon Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager-10 Perl: 5.22.1 OS: linux Time: Sat Feb 23 15:24:11 2019

 

 Message: No deployments found in Database!

 

 Traceback (14479):

   Module: Kernel::System::SysConfig::ConfigurationDeploySync Line: 3741

   Module: (eval) Line: 129

   Module: Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager::Run Line: 116

   Module: (eval) Line: 314

   Module: main::Start Line: 314

   Module: bin/otrs.Daemon.pl Line: 135

 

 

 

 Traceback (14479):

   Module: Kernel::System::Daemon::DaemonModules::BaseTaskWorker::_HandleError Line: 52

   Module: Kernel::System::Daemon::DaemonModules::SystemConfigurationSyncManager::Run Line: 134

   Module: (eval) Line: 314

   Module: main::Start Line: 314

   Module: bin/otrs.Daemon.pl Line: 135

 

By: Larry Braziel

I'm also having that same error when starting the Daemon.  When I try to pull up OTRS in the web browser, it won't load.  Any idea on how to fix this?  Something broke somewhere along the way.

By: Zee

Hi, any resolution for this issue? I am hitting the same error. installed Otrs 6 on Ubuntu 16.04

By: Hardi

Hi,

i did the DB configuration based on the provided instruction from this article, but when i exicute the following DB commands & insert otrs DB user i receives the following error message;

 

su - postgrescd /opt/otrs/thenpsql -U otrs -W -f scripts/database/otrs-schema.postgresql.sql otrspsql -U otrs -W -f scripts/database/otrs-initial_insert.postgresql.sql otrspsql -U otrs -W -f scripts/database/otrs-schema-post.postgresql.sql otrserror message is:psql: FATAL: Peer authentication failed for user "otrs"however i reviewed the user configuration still the same pssword (myotrspw) was configured.tappreciate your advice

 

By: Hardi

Hi  when run the following command, there is no information dispays from the page

vim /etc/postgresql/9.5/main/pg_hba.conf

By: Yellowbird

A blank page in this case means the file doesnt exist.  It could mean that you're using a different version of postgres.  Navigate to /etc/postgresql and type the ls command.  See whether there is a /9.5 folder or if it has another number.  Navigate into that folder (whatever number it is), then main, then you should find the pg_hba.conf file.

By: Silvio Moreira Santana

Amazing document ... excellent configuration job. Clap my hands to you for hard work!

Thank you a lot! It work's at first in Ubuntu 19.04 too.

By: Jaka

ANOTHER TROUBLESHOOT INFO:

in case you come to the far end and when starting the otrs.Daemon.pl you get "Use of uninitialized value in lc at bin/otrs.Daemon.pl line XXX" try to execute "perl bin/otrs.Console.pl Maint::Config::Rebuild". I had the error on either 575 or 518 for the log rotation but I couldn't find any answers. Ran the command and the daemon started without any problems. Also if you are using a different server and the above link for OTRS won't work DON'T forget the "/" at the end. Also gave me problems for some time (i had myip/otrs and it didn't work, apache gave out error. tried myip/otrs/ and it worked)

(bold text for main problems)

Hope it helps!!