如何在Ubuntu 16.04上安装OTRS(开源问题单系统)

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介:

如何在Ubuntu 16.04上安装OTRS(开源问题单系统)

OTRS ,即开源问题单(ticket)申请系统,是一个用于客户服务、帮助台和 IT 服务管理的开源问题单软件。该软件是用 Perl 和 javascript 编写的。对于那些需要管理票据、投诉、支持请求或其他类型的报告的公司和组织来说,这是一个问题单解决方案。OTRS 支持包括 MySQL、PostgreSQL、Oracle 和 SQL Server 在内的多个数据库系统,它是一个可以安装在 Windows 和 Linux 上的多平台软件。

在本教程中,我将介绍如何在 Ubuntu 16.04 上安装和配置 OTRS。我将使用 PostgreSQL 作为 OTRS 的数据库,将 Apache Web 服务器用作 Web 服务器。

先决条件

  • Ubuntu 16.04。
  • 最小 2GB 的内存。
  • root 权限

步骤 1 - 安装 Apache 和 PostgreSQL

在第一步中,我们将安装 Apache Web 服务器以及 PostgreSQL。我们将从 ubuntu 仓库中使用最新的版本。

使用 SSH 登录到你的 Ubuntu 服务器中:

 
 
  1. ssh root@192.168.33.14 

更新 Ubuntu 仓库。

 
 
  1. sudo apt-get update 

使用 apt 安装 Apache2 以及 PostgreSQL:

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

通过检查服务器端口确保 Apache 以及 PostgreSQL 运行了。

 
 
  1. netstat -plntu 

Install Apache and PostgreSQL

你可以看到 80 端口被 apache 使用了,5432 端口被 postgresql 数据库使用了。

步骤 2 - 安装 Perl 模块

OTRS 基于 Perl,因此我们需要安装一些 OTRS 需要的 Perl 模块。

使用这个 apt 命令安装 perl 模块:

 
 
  1. 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 

安装完成后,我们需要为 apache 激活 Perl 模块,接着重启 apache 服务。

 
 
  1. a2enmod perl 
  2. systemctl restart apache2 

接下来,使用下面的命令检查模块是否已经加载了:

 
 
  1. apachectl -M | sort 

Enable Apache Perl Module

Enable Apache Perl Module

你可以在 “Loaded Modules” 部分下看到 perl_module。

步骤 3 - 为 OTRS 创建新用户

OTRS 是一个基于 web 的程序并且运行与 apache web 服务器下。为了安全,我们需要以普通用户运行它,而不是 root 用户。

使用 useradd 命令创建一个 otrs 新用户:

 
 
  1. useradd -r -d /opt/otrs -c 'OTRS User' otrs 
  • -r:将用户作为系统用户。
  • -d /opt/otrs:在 /opt/otrs 下放置新用户的主目录。
  • -c:备注。

接下来,将 otrs 用户加入到 www-data 用户组,因为 apache 运行于 www-data 用户及用户组。

 
 
  1. usermod -a -G www-data otrs 

在 /etc/passwd 文件中已经有 otrs 用户了。

 
 
  1. grep -rin otrs /etc/passwd 

Create new user for OTRS

Create new user for OTRS

OTRS 的新用户已经创建了。

步骤 4 - 创建和配置数据库

在这节中,我们会为 OTRS 系统创建一个新 PostgreSQL 数据库,并对 PostgreSQL 数据库的配置做一些小的更改。

登录到 postgres 用户并访问 PostgreSQL shell。

 
 
  1. su - postgres
  2. psql 

创建一个新的角色 otrs,密码是 myotrspw,并且是非特权用户。

 
 
  1. create user otrs password 'myotrspw' nosuperuser; 

接着使用 otrs 用户权限创建一个新的 otrs 数据库:

 
 
  1. create database otrs owner otrs; 
  2. \q 

接下来为 otrs 角色验证编辑 PostgreSQL 配置文件。

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

在 84 行后粘贴下面的配置:

 
 
  1. local   otrs            otrs                                    password 
  2. host    otrs            otrs            127.0.0.1/32            password 

保存文件并退出 vim

Database Authentication OTRS

Database Authentication OTRS

使用 exit 回到 root 权限并重启 PostgreSQL:

 
 
  1. exit 
  2. systemctl restart postgresql 

PostgreSQL 已经为 OTRS 的安装准备好了。

Configure PostgreSQL for OTRS

Configure PostgreSQL for OTRS

步骤 5 - 下载和配置 OTRS

在本教程中,我们会使用 OTRS 网站中最新的版本。

进入 /opt 目录并使用 wget 命令下载 OTRS 5.0:

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

展开该 otrs 文件,重命名目录并更改所有 otrs 的文件和目录的所属人为 otrs。

 
 
  1. tar -xzvf otrs-5.0.16.tar.gz 
  2. mv otrs-5.0.16 otrs 
  3. chown -R otrs:otrs otrs 

接下来,我们需要检查系统并确保可以安装 OTRS 了。

使用下面的 otrs 脚本命令检查 OTRS 安装需要的系统软件包:

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

确保所有的结果是对的,这意味着我们的服务器可以安装 OTRS 了。

OTRS Chek Module needed for Installation

OTRS Chek Module needed for Installation

OTRS 已下载,并且我们的服务器可以安装 OTRS 了。

接下,进入 otrs 目录并复制配置文件。

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

使用 vim 编辑 Config.pm 文件:

 
 
  1. vim Kernel/Config.pm 

更改 42 行的数据库密码:

 
 
  1. $Self->{DatabasePw} = 'myotrspw'

注释 45 行的 MySQL 数据库支持:

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

取消注释 49 行的 PostgreSQL 数据库支持:

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

保存文件并退出 vim。

接着编辑 apache 启动文件来启用 PostgreSQL 支持。

 
 
  1. vim scripts/apache2-perl-startup.pl 

取消注释 60 和 61 行:

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

保存文件并退出编辑器。

最后,检查缺失的依赖和模块。

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

你可以在下面的截图中看到结果是 “OK”:

Check all modules again

步骤 6 - 导入样本数据库

在本教程中,我们会使用样本数据库,这可以在脚本目录中找到。因此我们只需要将所有的样本数据库以及表结构导入到第 4 步创建的数据库中。

登录到 postgres 用户并进入 otrs 目录中。

 
 
  1. su - postgres
  2. cd /opt/otrs/ 

作为 otrs 用户使用 psql 命令插入数据库以及表结构。

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

在需要的时候输入数据库密码 myotrspw。

Import OTRS Sample Database

Import OTRS Sample Database

步骤 7 - 启动 OTRS

数据库以及 OTRS 已经配置了,现在我们可以启动 OTRS。

将 otrs 的文件及目录权限设置为 www-data 用户和用户组。

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

通过创建一个新的链接文件到 apache 虚拟主机目录中启用 otrs apache 配置。

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

启用 otrs 虚拟主机并重启 apache。

 
 
  1. a2ensite otrs 
  2. systemctl restart apache2 

确保 apache 启动没有错误。

Enable OTRS Apache Virtual Host

Enable OTRS Apache Virtual Host

步骤 8 - 配置 OTRS 计划任务

OTRS 已经安装并运行在 Apache Web 服务器中了,但是我们仍然需要配置 OTRS 计划任务。

登录到 otrs 用户,接着以 otrs 用户进入 var/cron 目录。

 
 
  1. su - otrs 
  2. cd var/cron/
  3. pwd 

使用下面的命令复制所有 .dist 计划任务脚本:

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

使用 exit 回到 root 权限,并使用 otrs 用户启动计划任务脚本。

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

Enable OTRS Cron

Enable OTRS Cron

接下来,手动收取电子邮件的 PostMaster 创建一个新的计划任务。我会配置为每 2 分钟收取一次邮件。

 
 
  1. su - otrs 
  2. crontab -e 

粘贴下面的配置:

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

保存并退出。

现在停止 otrs 守护进程并再次启动。

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

Enable OTRS Fetching Email

Enable OTRS Fetching Email

OTRS 安装以及配置完成了。

步骤 9 - 测试 OTRS

打开你的 web 浏览器并输入你的服务器 IP 地址: http://192.168.33.14/otrs/

使用默认的用户 root@localhost 以及密码 root 登录。

Installation Successfully OTRS Home Page

使用默认的 root 账户你会看到一个警告。点击警告信息来创建一个新的 admin root 用户。

下面是用另外的 admin root 用户登录后出现的 admin 页面,这里没有出现错误信息。

OTRS Admin Dashboard Without Error Messages

如果你想作为客户登录,你可以使用 customer.pl :http://192.168.33.14/otrs/customer.pl

你会看到客户登录界面,输入客户的用户名和密码。

OTRS Customer Login Page

OTRS Customer Login Page

下面是一个创建新单据的客户页面。

Customer Open Ticket

Customer Open Ticket

步骤 10 - 疑难排查

如果你仍旧看到 “OTRS Daemon is not running” 的错误,你可以像这样调试 OTRS 守护进程。

 
 
  1. su - otrs 
  2. cd /opt/otrs/ 

停止 OTRS 守护进程:

 
 
  1. bin/otrs.Daemon.pl stop 

使用 --debug 选项启动 OTRS 守护进程。

 
 
  1. bin/otrs.Daemon.pl start --debug 



作者:Muhammad Arul
来源:51CTO
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
16天前
|
Ubuntu Windows
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
【Ubuntu/Arm】Ubuntu 系统如何链接有线网络(非虚拟机)?
|
21天前
|
Ubuntu NoSQL 关系型数据库
Ubuntu系统下安装常用软件
Ubuntu系统下安装常用软件
42 0
Ubuntu系统下安装常用软件
|
1月前
|
Ubuntu Linux C语言
Ubuntu下安装vscode,并解决终端打不开vscode的问题
Ubuntu下安装vscode,并解决终端打不开vscode的问题
134 0
|
1月前
|
Ubuntu Docker 容器
如何在Ubuntu上安装Docker?
【2月更文挑战第10天】
239 0
|
16天前
|
Ubuntu Linux 网络安全
【ubuntu】MobaXtem远程登录ubuntu系统(或虚拟机)
【ubuntu】MobaXtem远程登录ubuntu系统(或虚拟机)
|
23天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 中apt 安装MySQL数据库
Ubuntu 中apt 安装MySQL数据库
66 0
|
2天前
|
Ubuntu 数据安全/隐私保护
在UBUNTU虚拟机上安装R软件包
在UBUNTU虚拟机上安装R软件包
|
2天前
|
存储 编解码 Ubuntu
0-零基础安装ubuntu(超详细安装步骤)
0-零基础安装ubuntu(超详细安装步骤)
|
3天前
|
Ubuntu Linux 定位技术
手把手教你优雅的安装虚拟机 Ubuntu —— 图文并茂
手把手教你优雅的安装虚拟机 Ubuntu —— 图文并茂
|
17天前
|
Ubuntu Linux 虚拟化
【Linux】ubuntu安装samba服务器
【Linux】ubuntu安装samba服务器