Установка из исходных кодов (Linux, Unix)

Подготовка к установке из исходных кодов

If you want to install OTRS from source, first download the source archive as .tar.gz, .tar.bz2, or .zip file from http://www.otrs.com/try/

Распакуйте архив (например с помощью команды tar) в каталог /opt а затем переименуйте каталог otrs-x.x.x на otrs (см. ниже Сценарий ниже).

linux:/opt# tar xf /tmp/otrs-x.x.x.tar.gz
linux:/opt# mv otrs-x.x.x otrs
linux:/opt# ls
otrs
linux:/opt#

Script: Установка OTRS, первые шаги.

OTRS should NOT be run with root rights. Next you should add a new user for OTRS. The home directory of this new user should be /opt/otrs. If your web server is not running with the same user rights as the new 'otrs' user, which is the case on most systems, you will need to add the new 'otrs' user to the group of the web server user (see Script below).

linux:/opt# useradd -r -d /opt/otrs/ -c 'OTRS user' otrs
linux:/opt# usermod -G nogroup otrs
linux:/opt#

Сценарий: Добавление нового пользователя 'otrs' и добавление его в группу.

Next, you have to copy some sample configuration files. The system will later use the copied files. The files are located in /opt/otrs/Kernel and /opt/otrs/Kernel/Config and have the suffix .dist (see Script below).

linux:/opt# cd otrs/Kernel/
linux:/opt/otrs/Kernel# cp Config.pm.dist Config.pm
linux:/opt/otrs/Kernel# cd Config
linux:/opt/otrs/Kernel/Config# cp GenericAgent.pm.dist GenericAgent.pm

Сценарий: Копирование демонстрационных копий конфигурационных файлов

На завершающем этапе установки OTRS необходимо установить соответствующие права доступа к файлам. Для этого используйте сценарий otrs.SetPermissions.pl, находящийся в директории bin домашнего каталога пользователя 'otrs'. Скрипт можно вызвать со следующими параметрами:

otrs.SetPermissions.pl { Home directory of the OTRS user } { --otrs-user= OTRS user } { --web-user= Web server user } [ --otrs-group= Group of the OTRS user ] [ --web-group= Group of the web server user ]

Если ваш веб-сервер работает с теми же правами что и пользователь 'otrs', то команда установки надлежащих прав доступа будет выглядеть так: otrs.SetPermissions.pl /opt/otrs --otrs-user=otrs --web-user=otrs. На SUSE-системах веб-сервер работает с правами пользователя 'wwwrun'. На Debian-системах - 'www-data'. Для установки надлежащих прав доступа используйте команду otrs.SetPermissions.pl /opt/otrs --otrs-user=otrs --web-user=wwwrun --otrs-group=nogroup --web-group=www.

Установка Perl-модулей

OTRS requires some additional Perl modules, as described in Table 3-1. If you install OTRS from source, you will need to install these modules manually. This can be done either with the package manager of your Linux distribution (yast, apt-get) or, as described in this section, through the Perl shell and CPAN. If you're using ActiveState Perl, for instance on Windows, you could use PPM, the built-in Perl Package Manager. We recommend using your package manager if possible.

You can verify which modules you need to install with otrs.CheckModules.pl. This script is located in the bin directory, in the home directory of the 'otrs' user (see Script below). Please note that some modules are optional.

linux:~# cd /opt/otrs/bin/
linux:/opt/otrs/bin# ./otrs.CheckModules.pl
   o CGI..............................ok (v3.60)
   o Crypt::PasswdMD5.................ok (v1.3)
   o Crypt::SSLeay....................Not installed! (Optional - Required for Generic Interface SOAP SSL connections.)
   o CSS::Minifier....................ok (v0.01)
   o Date::Format.....................ok (v2.22)
   o Date::Pcalc......................ok (v1.2)

   ...

Сценарий: Проверка необходимых модулей.

You should strive to install the missing modules from your Linux distribution's package management system. By doing so, the packages will be automatically updated when new versions are available or when security issues are found. Please refer to your distribution's documentation on how to install additional packages. If the (correct version of) the module is not available from the package repositories, you can also install from CPAN, the Comprehensive Perl Archive Network.

Для установки любого из выше описанных модулей через CPAN, нужно выполнить команду perl -e shell -MCPAN. Оболочка Perl запустится в интерактивном режиме и модуль CPAN будет загружен. Если CPAN уже сконфигурирован, то с помощью команды install "имя модуля" (install module_name) можно начинать установку необходимых модулей. CPAN автоматически отслеживает зависимости между Perl-модулями и тут же оповещает, какие еще модули нужно установить.

Execute also the commands perl -cw bin/cgi-bin/index.pl perl -cw bin/cgi-bin/customer.pl and perl -cw bin/otrs.PostMaster.pl after changing into the directory /opt/otrs. If the output of both commands is "syntax OK", your Perl is properly set up (see Script below).

linux:~# cd /opt/otrs
linux:/opt/otrs# perl -cw bin/cgi-bin/index.pl
cgi-bin/installer.pl syntax OK
linux:/opt/otrs# perl -cw bin/cgi-bin/customer.pl
cgi-bin/customer.pl syntax OK
linux:/opt/otrs# perl -cw bin/otrs.PostMaster.pl
bin/otrs.PostMaster.pl syntax OK
linux:/opt/otrs#

Сценарий: Проверить синтаксис.

Настройка веб-сервера Apache

First of all, you should install the Apache2 web server and mod_perl; you'd typically do this from your systems package manager. Below you'll find the commands needed to set up Apache on the most popular Linux distributions.


    # rhel / centos:
    linux:# yum install httpd mod_perl

    # suse:
    linux:# zypper install apache2-mod_perl

    # debian/ubuntu:
    linux:# apt-get install apache2 libapache-mod-perl2

  

To access the web interface of OTRS via a short URL, Alias and ScriptAlias entries are needed. Most Apache installations have a conf.d directory included. On Linux systems you can usually find this directory under /etc/apache or /etc/apache2. Log in as root, change to the conf.d directory and copy the appropriate template in /opt/otrs/scripts/apache2-httpd.include.conf to a file called otrs.conf in the Apache configuration directory.

Перезагрузите веб-сервер, чтобы новые настройки вступили в силу. На большинстве систем запустить/перезагрузить веб-сервер можно с помощью команды /etc/init.d/apache2 restart (см. Сценарий ниже).

linux:/etc/apache2/conf.d# /etc/init.d/apache2 restart
Forcing reload of web server: Apache2.
linux:/etc/apache2/conf.d#

Сценарий: Перезапуск веб-сервера.

Теперь веб-сервер полностью настроен для работы OTRS.

Настройка базы данных

Установка базы данных OTRS вручную.

The recommended way to configure the database is to run the Web Installer. If you can't use this for some reason, you can also configure the database manually, as described in this chapter. If you can't use the web installer to setup the OTRS database, you have to set it up manually. Scripts with the SQL statements to create and configure the database are located in scripts/database, in the home directory of the 'otrs' user (see Script below).

linux:~# cd /opt/otrs/scripts/database/
linux:/opt/otrs/scripts/database# ls
otrs-initial_insert.db2.sql         otrs-schema.mysql.sql
otrs-schema.oracle.sql
otrs-initial_insert.mssql.sql       otrs-schema-post.db2.sql
otrs-initial_insert.mysql.sql       otrs-schema.postgresql.sql
otrs-initial_insert.oracle.sql
otrs-initial_insert.postgresql.sql  otrs-schema-post.mssql.sql
otrs-initial_insert.xml             otrs-schema-post.mysql.sql
otrs-schema.db2.sql                 otrs-schema-post.oracle.sql
 otrs-schema-post.postgresql.sql
otrs-schema.mssql.sql               otrs-schema.xml
linux:/opt/otrs/scripts/database#

Сценарий: Файлы, необходимые для создания и настройки базы данных.

При установке базы данных, для различных СУБД существует свой, определенный порядок обработки .sql-файлов.

Создание базы данных OTRS вручную, шаг за шагом

  1. Создание базы данных: Используя интерфейс базы данных или свой любимый менеджер баз даных, создайте базу данных, которую планируете использовать для OTRS.

  2. Создание таблиц: Используя файлы otrs-schema.DatabaseType.sql (например otrs-schema.oracle.sql, otrs-schema.postgresql.sql) можно создать таблицы в базе данных для OTRS.

  3. Inserting the initial system data: OTRS needs some initial system data to work properly (e.g. the different ticket states, ticket and notification types). Depending on the type of database that you are using, you will need to use one of the following files: otrs-initial_insert.mysql.sql, otrs-initial_insert.oracle.sql, otrs-initial_insert.postgresql.sql or otrs-initial_insert.mssql.sql .

  4. Создание связей между таблицами: Последний шаг - создание связей между различными таблицами базы данных OTRS Для этого используйте файл otrs-schema-post.DatabaseType.sql (например otrs-schema-oracle.post.sql, otrs-schema-post.postgresql.sql).

После завершения установки базы данных необходимо проверить и установить соответствующие права доступа для базы данных OTRS. Сделать это необходимо так, чтобы только один пользователь имел соответствующие права доступа. Настройка прав доступа отличается в зависимости от выбраного вами сервера базы данных и должна производится с помощью графического интерфейса базы данных или с помощью программы клиента.

If your database and the access rights are configured properly, you have to tell OTRS which database back-end you want to use and how the ticket system can connect to the database. Open the file Kernel/Config.pm located in the home directory of the 'otrs' user, and change the parameters shown in the script below according to your needs.


    # DatabaseHost
    # (The database host.)
    $Self->{'DatabaseHost'} = 'localhost';

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

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

    # DatabasePw
    # (The password of database user.)
    $Self->{DatabasePw} = 'some-pass';

Сценарий: Настраиваемые параметры

Настрой планировщика задач (cron jobs) для OTRS

Для правильной работы системы OTRS необходим планировщик задач (cron jobs). Планировщик задач (cron jobs) должен запускаться с теми же правами, что и модули OTRS. Именно по этому cron jobs должен быть внесен в crontab-файл пользователя 'otrs'.

All scripts with the cron jobs are located in var/cron, in the home directory of the 'otrs' user (see Script below).

linux:~# cd /opt/otrs/var/cron
linux:/opt/otrs/var/cron# ls
aaa_base.dist                generic_agent.dist       rebuild_ticket_index.dist
cache.dist                   pending_jobs.dist        session.dist
fetchmail.dist               postmaster.dist          unlock.dist
generic_agent-database.dist  postmaster_mailbox.dist
linux:/opt/otrs/var/cron#

Сценарий: Файлы, необходимые для создания заданий планировщика задач (cron jobs).

These scripts have a suffix of '.dist'. You should copy them to files with the suffix removed. If you use bash, you might want to use the command listed in Script below.

linux:/opt/otrs/var/cron# for foo in *.dist; do cp $foo `basename $foo .dist`; done
linux:/opt/otrs/var/cron# ls
aaa_base                generic_agent-database.dist  rebuild_ticket_index
aaa_base.dist           generic_agent.dist           rebuild_ticket_index.dist
cache                   pending_jobs                 session
cache.dist              pending_jobs.dist            session.dist
fetchmail               postmaster                   unlock
fetchmail.dist          postmaster.dist              unlock.dist
generic_agent           postmaster_mailbox
generic_agent-database  postmaster_mailbox.dist
linux:/opt/otrs/var/cron#

Script: Copying and renaming all the files needed to create the cron jobs.

В Таблице 3-2 приводятся различные задания cron jobs.

Таблица 2.1. Описание некоторых сценариев планировщика задач cron job.

Сценарий Назначение
aaa_base Определяет основные настройки для crontab пользователя 'otrs'.
cache Удаляет из диска устаревшие ("просроченные") кэш-записи. Очищает кэш-погрузчик для CSS и JavaScript файлов.
fetchmail Этот сценарий может быть использован в том случае, если новые емейлы будут поступать в систему обработки заявок через fetchmail.
generic_agent Выполняет задания из GenericAgent, которые не сохраняются в базе данных, а в собственных конфиг-файлах.
generic_agent-database Выполняет задания из GenericAgent, которые хранятся в базе данных.
pending_jobs Проверяет систему на наличие заявок, ожидающих решения, закрывает их или отсылает напоминание, если это необходимо.
postmaster Проверяет очередь сообщений системы обработки заявок, и доставляет те сообщения, которые находятся в этой очереди.
postmaster_mailbox Получает почту с POP3-счетов, которые были указаны в админке, в разделе "Учетные записи PostMaster".
rebuild_ticket_index Восстанавливает индекс заявки, что значительно повышает скорость просмотра заявок в разделе QueueView.
session Удаляет старые и больше не используемые ID-сессий (session IDs).
unlock Открывает заявки, которые были ранее заблокированы в системе.


To setup all cron jobs, the script bin/Cron.sh located in the home directory of the 'otrs' user can be used. When this script is executed, it needs a parameter to specify whether you want to install, remove, or reinstall the cron jobs. The following parameters can be used:

Cron.sh { start } { stop } { restart } [ OTRS user ]

Because the cron jobs need to be installed in the crontab file of the 'otrs' user, you need to be logged in as 'otrs'. If you are logged in as root, you can switch to 'otrs' with the command su otrs. Execute the commands specified in Script below to install the cron jobs.

Предупреждение

Обратите внимание, что при использовании файла Cron.sh другие задания, установленные в crontab-файле для пользователя 'otrs' будут перезаписаны или удалены. Внесите все необходимые изменения в файл Cron.sh, чтобы сохранить другие crontab-задания.

linux:/opt/otrs/var/cron# cd /opt/otrs/bin/
linux:/opt/otrs/bin# su otrs
linux:~/bin$ ./Cron.sh start
/opt/otrs/bin
Cron.sh - start/stop OTRS cronjobs
Copyright (C) 2001-2009 OTRS AG, http://otrs.org/
(using /opt/otrs) done
linux:~/bin$ exit
exit
linux:/opt/otrs/bin#

Сценарий: Установка cron jobs.

Команда crontab -l -u otrs, которую можно запускать с правами администратора, отображает содержание crontab-файла пользователя 'otrs', так что можно легко проверить правильность расположения всех записей (см. Сценарий ниже).

linux:/opt/otrs/bin# crontab -l -u otrs
# --
# cron/aaa_base - base crontab package
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# Who gets the cron emails?
MAILTO="root@localhost"

# --
# cron/cache - delete expired cache
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# delete expired cache weekly (Sunday mornings)
20 0 * * 0  $HOME/bin/otrs.CacheDelete.pl --expired >> /dev/null
30 0 * * 0  $HOME/bin/otrs.LoaderCache.pl -o delete >> /dev/null

# --
# cron/fetchmail - fetchmail cron of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# fetch every 5 minutes emails via fetchmail
#*/5 * * * * /usr/bin/fetchmail -a >> /dev/null

# --
# cron/generic_agent - otrs.GenericAgent.pl cron of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# start generic agent every 20 minutes
*/20 * * * * $HOME/bin/GenericAgent.pl >> /dev/null
# example to execute GenericAgent.pl on 23:00 with
# Kernel::Config::GenericAgentMove job file
#0 23 * * * $HOME/bin/otrs.GenericAgent.pl -c "Kernel::Config::GenericAgentMove" >> /dev/null
# --
# cron/generic_agent - GenericAgent.pl cron of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# start generic agent every 10 minutes
*/10 * * * * $HOME/bin/otrs.GenericAgent.pl -c db >> /dev/null
# --
# cron/pending_jobs - pending_jobs cron of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# check every 120 min the pending jobs
45 */2 * * * $HOME/bin/otrs.PendingJobs.pl >> /dev/null
# --
# cron/postmaster - postmaster cron of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# check daily the spool directory of OTRS
10 0 * * *  $HOME/bin/otrs.ReprocessMails.pl >> /dev/null
# --
# cron/postmaster_mailbox - postmaster_mailbox cron of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# fetch emails every 10 minutes
*/10 * * * * $HOME/bin/otrs.PostMasterMailbox.pl >> /dev/null
# --
# cron/rebuild_ticket_index - rebuild ticket index for OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# just every day
01 01 * * * $HOME/bin/otrs.RebuildTicketIndex.pl >> /dev/null

# --
# cron/session - delete old session ids of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# delete every 120 minutes old/idle session ids
55 */2 * * * $HOME/bin/otrs.DeleteSessionIDs.pl --expired >> /dev/null

# --
# cron/unlock - unlock old locked ticket of the OTRS
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY.
# --
# unlock every hour old locked tickets
35 * * * * $HOME/bin/otrs.UnlockTickets.pl --timeout >> /dev/null

linux:/opt/otrs/bin#

Сценарий: Файл Crontab.

OTRS Scheduler Service

OTRS comes with a scheduler service that is used to perform asynchronous tasks.

The OTRS RPMs will set up the Scheduler Service automatically. If you install from source, you can install the service by copying the scripts/otrs-scheduler-linux file to /etc/init.d and giving it the appropriate permissions. This will make sure the scheduler service starts when the system starts up.