1. 安装perl
yum install -y perl
2. 下载help desk源码
wget http://ftp.otrs.org/pub/otrs//otrs-3.3.7.tar.bz2
3. 解压到/opt/
tar -jxvf otrs-3.3.7.tar.bz2
4. 重命名为otrs
mv otrs-3.3.7 /opt/otrs
5. 创建一个普通用户, 用于运行otrs. 同时需要将它的HOME目录设置为/opt/otrs
useradd -r -d /opt/otrs/ -c 'OTRS user' otrs
6. 如果系统运行web server的用户不是otrs用户, 那么需要把otrs用户添加到运行web server用户的组.
usermod -G apache otrs
# id otrs
uid=495(otrs) gid=491(otrs) groups=491(otrs),48(apache)
7. 拷贝配置文件模板
[root@db-172-16-3-150 soft_bak]# cd /opt/otrs/Kernel/
[root@db-172-16-3-150 Kernel]# cp Config.pm.dist Config.pm
[root@db-172-16-3-150 Kernel]# cd Config
[root@db-172-16-3-150 Config]# cp GenericAgent.pm.dist GenericAgent.pm
8. 设置权限
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 ]
执行结果如下
# /opt/otrs/bin/otrs.SetPermissions.pl /opt/otrs --otrs-user=otrs --otrs-group=otrs --web-user=otrs --web-group=apache
bin/otrs.SetPermissions.pl - set OTRS file permissions
Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
Setting permissions on /opt/otrs
Setting permissions on /opt/otrs/var
Setting permissions on /opt/otrs/bin/*
Setting permissions on /opt/otrs/scripts/
Setting permissions on /opt/otrs/Kernel/Config.pm
9. 安装perl模块
查看需要安装的perl模块.
[root@db-172-16-3-150 ~]# /opt/otrs/bin/otrs.CheckModules.pl
o Crypt::Eksblowfish::Bcrypt.......Not installed! (optional - For strong password hashing.)
o Crypt::SSLeay....................ok (v0.57)
o Date::Format.....................ok (v2.22)
o DBI..............................ok (v1.609)
o DBD::mysql.......................ok (v4.013)
o DBD::ODBC........................Not installed! (optional - Required to connect to a MS-SQL database.)
o DBD::Oracle......................Not installed! (optional - Required to connect to a Oracle database.)
o DBD::Pg..........................Not installed! (optional - Required to connect to a PostgreSQL database.)
o Encode::HanExtra.................Not installed! (optional - Required to handle mails with several Chinese character sets.)
o GD...............................Not installed! (optional - Required for stats.)
o GD::Text.......................Not installed! (optional - Required for stats.)
o GD::Graph......................Not installed! (optional - Required for stats.)
o IO::Socket::SSL..................Not installed! (optional - Required for SSL connections to web and mail servers.)
o JSON::XS.........................Not installed! (optional - Recommended for faster AJAX/JavaScript handling.)
o List::Util::XS...................ok (v1.21)
o LWP::UserAgent...................ok (v6.05)
o Mail::IMAPClient.................Not installed! (optional - Required for IMAP TLS connections.)
o IO::Socket::SSL................Not installed! (optional - Required for IMAP TLS connections.)
o ModPerl::Util....................Not installed! (optional - Improves Performance on Apache webservers dramatically.)
o Net::DNS.........................Not installed! (required - Please install this module - )
o Net::LDAP........................Not installed! (optional - Required for directory authentication.)
o Net::SSL.........................ok (v2.84)
o PDF::API2........................Not installed! (optional - Required for PDF output.)
o Compress::Zlib.................ok (v2.021)
o Text::CSV_XS.....................Not installed! (optional - Recommended for faster CSV handling.)
o Time::HiRes......................ok (v1.9721)
o XML::Parser......................ok (v2.36)
o YAML::XS.........................Not installed! (required - Please install this module - )
安装前先检查一下perl CPAN是否配置正确.
[root@db-172-16-3-150 bin]# cd /opt/otrs/
[root@db-172-16-3-150 otrs]# perl -cw bin/cgi-bin/index.pl
bin/cgi-bin/index.pl syntax OK
[root@db-172-16-3-150 otrs]# perl -cw bin/cgi-bin/customer.pl
bin/cgi-bin/customer.pl syntax OK
[root@db-172-16-3-150 otrs]# perl -cw bin/otrs.PostMaster.pl
bin/otrs.PostMaster.pl syntax OK
安装缺失或需要的模块, 例如
perl -e shell -MCPAN
cpan[1]> install YAML
cpan[1]> install DBD::Pg
cpan[1]> install Encode::HanExtra
[注意]
1. 如果cpan没有配置好的话, 可以删掉~/.cpan/*, 重新配置一遍.
rm -rf /root/.cpan/*
perl -e shell -MCPAN
2. 安装DBD::Pg必须先安装DBI, PostgreSQL软件等. 详见DBD::Pg的README
cpan[1]> install DBI
cpan[1]> install Test::Simple
[root@db-172-16-3-150 DBD-Pg-3.3.0-pG7cPt]# export PATH=/home/pg93/pgsql/bin:$PATH
[root@db-172-16-3-150 DBD-Pg-3.3.0-pG7cPt]# which pg_config
/home/pg93/pgsql/bin/pg_config
[root@db-172-16-3-150 DBD-Pg-3.3.0-pG7cPt]# perl -e shell -MCPAN
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.
cpan[1]> install DBD::Pg
如果没有安装成功的话, 可以到.cpan/build/DBD::Pg...的目录中查看README, 看看如何安装.
REQUIREMENTS:
-------------
build, test, and install Perl 5 (at least 5.8.1)
build, test, and install the DBI module (at least 1.614)
build, test, and install PostgreSQL (at least 7.4)
build, test, and install Test::Simple (at least 0.47)
DBD::Pg needs to know where to find the libpq libraries: this is usually done
by checking the output of the pg_config executable. If pg_config is not available,
then you may need to install the development package for PostgreSQL. To do this
on Debian and Ubuntu, use: apt-get install postgresql-dev; on RedHat and CentOS,
use: yum install postgresql-devel. Note that the development libraries are needed
even if you already have PostgreSQL up and running.
10. 安装apache服务
# yum install -y httpd mod_perl
11. 配置otrs apache server alias
# cp /opt/otrs/scripts/apache2-httpd.include.conf /etc/httpd/conf.d/otrs.conf
12. 重启web server
# apachectl -k restart
# service httpd restart
13. 手工配置数据库, 也可以web页面下配置.
我们这里使用PostgreSQL
# cd /opt/otrs/scripts/database
[root@db-172-16-3-150 database]# ll
total 1036
-rw-rw---- 1 otrs apache 77845 Mar 27 18:01 otrs-initial_insert.mssql.sql
-rw-rw---- 1 otrs apache 78288 Mar 27 18:01 otrs-initial_insert.mysql.sql
-rw-rw---- 1 otrs apache 77922 Mar 27 18:01 otrs-initial_insert.oracle.sql
-rw-rw---- 1 otrs apache 77895 Mar 27 18:01 otrs-initial_insert.postgresql_before_8_2.sql
-rw-rw---- 1 otrs apache 77928 Mar 27 18:01 otrs-initial_insert.postgresql.sql
-rw-rw---- 1 otrs apache 96687 Mar 27 18:01 otrs-initial_insert.xml
-rw-rw---- 1 otrs apache 53610 Mar 27 18:01 otrs-schema.mssql.sql
-rw-rw---- 1 otrs apache 50407 Mar 27 18:01 otrs-schema.mysql.sql
-rw-rw---- 1 otrs apache 92424 Apr 22 15:35 otrs-schema.oracle.sql
-rw-rw---- 1 otrs apache 52445 Mar 27 18:01 otrs-schema.postgresql_before_8_2.sql
-rw-rw---- 1 otrs apache 52473 Mar 27 18:01 otrs-schema.postgresql.sql
-rw-rw---- 1 otrs apache 26617 Mar 27 18:01 otrs-schema-post.mssql.sql
-rw-rw---- 1 otrs apache 26614 Mar 27 18:01 otrs-schema-post.mysql.sql
-rw-rw---- 1 otrs apache 26111 Mar 27 18:01 otrs-schema-post.oracle.sql
-rw-rw---- 1 otrs apache 26633 Mar 27 18:01 otrs-schema-post.postgresql_before_8_2.sql
-rw-rw---- 1 otrs apache 26661 Mar 27 18:01 otrs-schema-post.postgresql.sql
-rw-rw---- 1 otrs apache 93249 Mar 27 18:01 otrs-schema.xml
drwxrwx--- 2 otrs apache 4096 Mar 27 18:01 update
首先需要创建用户, 表空间, 数据库, schema.
[root@db-172-16-3-150 database]# su - pg93
pg93@db-172-16-3-150-> psql
psql (9.3.3)
Type "help" for help.
digoal=# create role otrs nosuperuser login encrypted password 'test123';
CREATE ROLE
digoal=# create database otrs with template template0 encoding 'UTF8';
CREATE DATABASE
digoal=# grant all on database otrs to otrs;
GRANT
digoal=# \c otrs otrs
You are now connected to database "otrs" as user "otrs".
otrs=> create schema otrs;
CREATE SCHEMA
按顺序执行几个脚本
[root@db-172-16-3-150 database]# /home/pg93/pgsql/bin/psql -h 127.0.0.1 -p 1921 -U otrs otrs -f ./otrs-schema.postgresql.sql
[root@db-172-16-3-150 database]# /home/pg93/pgsql/bin/psql -h 127.0.0.1 -p 1921 -U otrs otrs -f ./otrs-initial_insert.postgresql.sql
[root@db-172-16-3-150 database]# /home/pg93/pgsql/bin/psql -h 127.0.0.1 -p 1921 -U otrs otrs -f ./otrs-schema-post.postgresql.sql
配置OTRS数据库连接
# vi /opt/otrs/Kernel/Config.pm
注释mysql的默认连接配置, 使用DBD::Pg, unixsock连接, 注意端口, 不是5432的话需要增加配置
sub Load {
my $Self = shift;
# ---------------------------------------------------- #
# database settings #
# ---------------------------------------------------- #
# The database host
$Self->{DatabaseHost} = '127.0.0.1';
$Self->{DatabasePort} = '1921';
# 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} = 'test123';
# The database DSN for MySQL ==> more: "perldoc DBD::mysql"
# $Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";
# The database DSN for PostgreSQL ==> more: "perldoc DBD::Pg"
# if you want to use a local socket connection
$Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};port=$Self->{DatabasePort};";
# if you want to use a TCP/IP connection
# $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};host=$Self->{DatabaseHost};";
# if you have PostgresSQL 8.1 or earlier, activate the legacy driver with this line:
# $Self->{DatabasePostgresqlBefore82} = 1;
14. 配置otrs用户的crontab
[root@db-172-16-3-150 DBD-Pg-3.3.0-pG7cPt]# cd /opt/otrs/var/cron/
[root@db-172-16-3-150 cron]# ll
total 52
-rw-rw---- 1 otrs apache 52 Apr 28 20:02 aaa_base.dist
-rw-rw---- 1 otrs apache 179 Apr 28 20:02 cache.dist
-rw-rw---- 1 otrs apache 180 Apr 28 20:02 fetchmail.dist
-rw-rw---- 1 otrs apache 106 Apr 28 20:02 generate_dashboard_stats.dist
-rw-rw---- 1 otrs apache 106 Apr 28 20:02 generic_agent-database.dist
-rw-rw---- 1 otrs apache 295 Apr 28 20:02 generic_agent.dist
-rw-rw---- 1 otrs apache 99 Apr 28 20:02 pending_jobs.dist
-rw-rw---- 1 otrs apache 101 Apr 28 20:02 postmaster.dist
-rw-rw---- 1 otrs apache 98 Apr 28 20:02 postmaster_mailbox.dist
-rw-rw---- 1 otrs apache 80 Apr 28 20:02 rebuild_ticket_index.dist
-rw-rw---- 1 otrs apache 87 Apr 28 20:02 scheduler_watchdog.dist
-rw-rw---- 1 otrs apache 123 Apr 28 20:02 session.dist
-rw-rw---- 1 otrs apache 107 Apr 28 20:02 unlock.dist
把.dist模板文件拷贝出来,
[root@db-172-16-3-150 cron]# for foo in *.dist; do cp $foo `basename $foo .dist`; done
[root@db-172-16-3-150 cron]# ll
total 104
-rw-r----- 1 root root 52 Jun 2 16:38 aaa_base
-rw-rw---- 1 otrs apache 52 Apr 28 20:02 aaa_base.dist
-rw-r----- 1 root root 179 Jun 2 16:38 cache
-rw-rw---- 1 otrs apache 179 Apr 28 20:02 cache.dist
-rw-r----- 1 root root 180 Jun 2 16:38 fetchmail
-rw-rw---- 1 otrs apache 180 Apr 28 20:02 fetchmail.dist
-rw-r----- 1 root root 106 Jun 2 16:38 generate_dashboard_stats
-rw-rw---- 1 otrs apache 106 Apr 28 20:02 generate_dashboard_stats.dist
-rw-r----- 1 root root 295 Jun 2 16:38 generic_agent
-rw-r----- 1 root root 106 Jun 2 16:38 generic_agent-database
-rw-rw---- 1 otrs apache 106 Apr 28 20:02 generic_agent-database.dist
-rw-rw---- 1 otrs apache 295 Apr 28 20:02 generic_agent.dist
-rw-r----- 1 root root 99 Jun 2 16:38 pending_jobs
-rw-rw---- 1 otrs apache 99 Apr 28 20:02 pending_jobs.dist
-rw-r----- 1 root root 101 Jun 2 16:38 postmaster
-rw-rw---- 1 otrs apache 101 Apr 28 20:02 postmaster.dist
-rw-r----- 1 root root 98 Jun 2 16:38 postmaster_mailbox
-rw-rw---- 1 otrs apache 98 Apr 28 20:02 postmaster_mailbox.dist
-rw-r----- 1 root root 80 Jun 2 16:38 rebuild_ticket_index
-rw-rw---- 1 otrs apache 80 Apr 28 20:02 rebuild_ticket_index.dist
-rw-r----- 1 root root 87 Jun 2 16:38 scheduler_watchdog
-rw-rw---- 1 otrs apache 87 Apr 28 20:02 scheduler_watchdog.dist
-rw-r----- 1 root root 123 Jun 2 16:38 session
-rw-rw---- 1 otrs apache 123 Apr 28 20:02 session.dist
-rw-r----- 1 root root 107 Jun 2 16:38 unlock
-rw-rw---- 1 otrs apache 107 Apr 28 20:02 unlock.dist
这些文件的描述
Table 2.1. Description of several cron job scripts.
Script | Function |
---|---|
aaa_base | Sets the basics for the crontab of the 'otrs' user. |
cache | Removes expired cache entries from disk. Clears the loader cache for CSS and JavaScript files. |
fetchmail | Used only if new mails will be fetched with fetchmail into the ticket system. |
generic_agent | Executes the jobs of the GenericAgent that are not stored in the database but in own config files. |
generic_agent-database | Executes the jobs of the GenericAgent that are stored in the database. |
pending_jobs | Checks system for pending tickets, and closes them or sends reminders if needed. |
postmaster | Checks the message queue of the ticket system, and delivers messages that are still in the queues. |
postmaster_mailbox | Fetches the mails from the POP3 accounts that were specified in the admin area, in the section for "PostMaster Mail Accounts". |
rebuild_ticket_index | Rebuilds the ticket index, which improves the speed of the QueueView. |
session | Removes old and no longer needed session IDs. |
unlock | Unlocks tickets in the system. |
执行Cron.sh
[root@db-172-16-3-150 cron]# chown -R otrs:apache /opt/otrs
[root@db-172-16-3-150 cron]# su - otrs
-bash-4.1$ cd /opt/otrs/bin/
-bash-4.1$ ./Cron.sh start
/opt/otrs/bin
Cron.sh - start/stop OTRS cronjobs
Copyright (C) 2001-2012 OTRS AG, http://otrs.org/
(using /opt/otrs) done
查看otrs用户的crontab是否设置
-bash-4.1$ crontab -l
# Who gets the cron emails?
MAILTO="root@localhost"
# delete expired cache weekly (Sunday mornings)
20 0 * * 0 $HOME/bin/otrs.DeleteCache.pl --expired >> /dev/null
30 0 * * 0 $HOME/bin/otrs.LoaderCache.pl -o delete >> /dev/null
# fetch every 5 minutes emails via fetchmail
#*/5 * * * * [ -x /usr/bin/fetchmail ] && /usr/bin/fetchmail -a >> /dev/null
#*/5 * * * * /usr/bin/fetchmail -a --ssl >> /dev/null
# generate dashboard stats every hour
5 * * * * $HOME/bin/otrs.GenerateDashboardStats.pl >> /dev/null
# start generic agent every 20 minutes
*/20 * * * * $HOME/bin/otrs.GenericAgent.pl >> /dev/null
# example to execute otrs.GenericAgent.pl on 23:00 with
# Kernel::Config::GenericAgentMove job file
#0 23 * * * $HOME/bin/otrs.GenericAgent.pl -c "Kernel::Config::GenericAgentMove" >> /dev/null
# start generic agent every 10 minutes
*/10 * * * * $HOME/bin/otrs.GenericAgent.pl -c db >> /dev/null
# check every 120 min the pending jobs
45 */2 * * * $HOME/bin/otrs.PendingJobs.pl >> /dev/null
# check daily the spool directory of OTRS
10 0 * * * $HOME/bin/otrs.ReprocessMails.pl >> /dev/null
# fetch emails every 10 minutes
*/10 * * * * $HOME/bin/otrs.PostMasterMailbox.pl >> /dev/null
# just every day
01 01 * * * $HOME/bin/otrs.RebuildTicketIndex.pl >> /dev/null
# check scheduler status
*/5 * * * * $HOME/bin/otrs.Scheduler.pl -w 1 >> /dev/null
# delete every 120 minutes old/idle session ids
55 */2 * * * $HOME/bin/otrs.DeleteSessionIDs.pl --expired >> /dev/null
# unlock every hour old locked tickets
35 * * * * $HOME/bin/otrs.UnlockTickets.pl --timeout >> /dev/null
15. 配置OTRS Scheduler Service,
在源码中未找到otrs-scheduler-linux文件. 建议使用rpm安装
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.
16. 配置web service.
http://172.16.3.150/otrs/installer.pl
这里会需要配置数据库, 所以前面数据库的要删掉. 并且只能连接5432默认端口.
pg93@db-172-16-3-150-> psql -h 127.0.0.1 -p 5432 -U otrs otrs
otrs=> drop schema otrs cascade;
使用web 配置的话, 会安装到public schema下.
配置邮件代理
参考
http://blog.163.com/digoal@126/blog/static/1638770402010411111337412/
# yum install -y sendmail-doc sendmail sendmail-cf
# vi /etc/mail/access
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:172.16 RELAY
[root@db-172-16-3-150 ~]# cd /etc/mail
[root@db-172-16-3-150 mail]# makemap hash access.db < access
[root@db-172-16-3-150 mail]# vi /etc/mail/sendmail.mc
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
# hostname
db-172-16-3-150.sky-mobi.com
[root@db-172-16-3-150 mail]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.3.33 db1
172.16.3.39 db1
172.16.3.150 db-172-16-3-150.sky-mobi.com
# vi /etc/mail/local-host-names
db-172-16-3-150.sky-mobi.com
[root@db-172-16-3-150 mail]# cat /etc/resolv.conf
# Generated by NetworkManager
search sky-mobi.com
nameserver 202.101.172.35
[root@db-172-16-3-150 mail]# ping 163.com
PING 163.com (123.58.180.8) 56(84) bytes of data.
64 bytes from 123.58.180.8: icmp_seq=1 ttl=56 time=1.95 ms
^C
--- 163.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 672ms
rtt min/avg/max/mdev = 1.956/1.956/1.956/0.000 ms
[root@db-172-16-3-150 mail]# netstat -anp|grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1052/smtpd
[参考]
1. http://blog.163.com/digoal@126/blog/static/163877040201442223425258/
5. http://otrs.github.io/doc/manual/admin/3.3/en/html/manual-installation-of-otrs.html
6. http://otrs.github.io/doc/manual/admin/3.3/en/html/index.html
7. http://blog.163.com/digoal@126/blog/static/1638770402010411111337412/
8. man basename