本教程适用于以下操作系统版本

  • Ubuntu 24.04(Noble Numbat)
  • Ubuntu 22.04(Jammy Jellyfish)

本页内容

  • 先决条件
  • 安装 Apache、MariaDB 和 PHP
  • 为 osTicket 创建数据库
  • 下载 osTicket
  • 创建 Apache 虚拟主机
  • 启动 osTicket 安装向导
  • 使用 Let's Encrypt SSL 保护 osTicket
  • 结论

osTicket 是一款开源的工单系统,也是中小型企业中使用最广泛的工单系统之一。它是一个简单易用的基于 Web 的客户支持门户,可帮助你管理和跟踪所有工单。osTicket 允许你定义工单路由规则,将工单发送给正确的人。你可以自定义并向工单中添加自己的 Logo、图片和视频。osTicket 支持多种数据库类型,例如 MySQL 和 PostgreSQL,并可与 LDAP/Active Directory 集成以实现集中式身份验证。

本文介绍了如何在 Ubuntu 22.04 上使用 Apache 安装 osTicket。

先决条件

  • 一台运行 Ubuntu 22.04 的服务器。
  • 一个指向你服务器 IP 的有效域名。
  • 服务器上已配置 root 密码。

安装 Apache、MariaDB 和 PHP

首先,你需要在服务器上安装 Apache Web 服务器、MariaDB、PHP 以及其他 PHP 扩展。你可以使用以下命令安装所有软件包。

apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-cgi php-fpm php-cli php-curl php-gd php-imap php-mbstring php-pear php-intl php-apcu php-common php-bcmath -y

所有软件包安装完成后,使用以下命令启动并启用 Apache 和 MariaDB 服务。

systemctl start apache2
systemctl enable apache2
systemctl start mariadb
systemctl enable mariadb

为 osTicket 创建数据库

首先,使用以下命令加固 MariaDB 安装。

mysql_secure_installation

回答所有问题以设置 MariaDB root 密码并加固安装:

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

接下来,使用以下命令登录 MariaDB shell。

mysql -u root -p

登录后,使用以下命令为 osTicket 创建数据库和用户。

MariaDB [(none)]> CREATE DATABASE osticket;
MariaDB [(none)]> CREATE USER 'osticket'@'localhost' IDENTIFIED BY 'securepassword';

接下来,使用以下命令授予 osTicket 数据库所有权限。

MariaDB [(none)]> GRANT ALL PRIVILEGES ON osticket.* TO osticket@localhost IDENTIFIED BY "securepassword";

接下来,使用以下命令刷新权限并退出 MariaDB shell。

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

完成后,你可以进入下一步。

下载 osTicket

首先,使用以下命令下载最新版本的 osTicket。

wget https://github.com/osTicket/osTicket/releases/download/v1.17.2/osTicket-v1.17.2.zip

osTicket 下载完成后,创建 osTicket 目录,并将下载的文件解压到该目录中。

mkdir /var/www/html/osticket
unzip osTicket-v1.17.2.zip -d /var/www/html/osticket

接下来,使用以下命令更改 osTicket 目录的所有权和权限:

chown -R www-data:www-data /var/www/html/osticket
chmod -R 755 /var/www/html/osticket

现在,使用以下命令重命名 osTicket 示例配置文件:

mv /var/www/html/osticket/upload/include/ost-sampleconfig.php /var/www/html/osticket/upload/include/ost-config.php

完成后,你可以进入下一步。

创建 Apache 虚拟主机

接下来,你需要为 osTicket 创建 Apache 虚拟主机配置文件。你可以使用以下命令创建它。

nano /etc/apache2/sites-available/osticket.conf

添加以下行:

<VirtualHost *:80>
        ServerName osticket.example.com
        ServerAdmin admin@localhost
        DocumentRoot /var/www/html/osticket/upload

        <Directory /var/www/html/osticket/upload>
                Require all granted
                Options FollowSymlinks
                AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/osticket.error.log
        CustomLog ${APACHE_LOG_DIR}/osticket.access.log combined
</VirtualHost>

完成后保存并关闭文件。然后,使用以下命令激活 osTicket 虚拟主机并启用 Apache rewrite 模块:

a2ensite osticket.conf
a2enmod rewrite

接下来,重启 Apache 服务以应用配置更改:

systemctl restart apache2

你可以使用以下命令检查 Apache 状态。

systemctl status apache2

你应该看到以下输出。

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-12-21 07:20:15 UTC; 3s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 62019 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 62023 (apache2)
      Tasks: 6 (limit: 2238)
     Memory: 15.4M
        CPU: 42ms
     CGroup: /system.slice/apache2.service
             ??62023 /usr/sbin/apache2 -k start
             ??62024 /usr/sbin/apache2 -k start
             ??62025 /usr/sbin/apache2 -k start
             ??62026 /usr/sbin/apache2 -k start
             ??62027 /usr/sbin/apache2 -k start
             ??62028 /usr/sbin/apache2 -k start

Dec 21 07:20:15 ubuntu2204 systemd[1]: apache2.service: Deactivated successfully.
Dec 21 07:20:15 ubuntu2204 systemd[1]: Stopped The Apache HTTP Server.
Dec 21 07:20:15 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

启动 osTicket 安装向导

你现在可以使用 URL http://osticket.example.com 启动 osTicket 安装向导。你应该会看到以下页面。

在 Ubuntu 22.04 上通过 Apache 部署 osTicket 工单系统教程

点击 Continue(继续)。你应该会看到基础安装页面。

在 Ubuntu 22.04 上通过 Apache 部署 osTicket 工单系统教程

在 Ubuntu 22.04 上通过 Apache 部署 osTicket 工单系统教程

填写你的帮助台 URL、名称、邮箱、数据库名称、用户名、密码,然后点击 Install Now(立即安装)按钮开始安装。osTicket 安装完成后,你应该会看到以下页面。

在 Ubuntu 22.04 上通过 Apache 部署 osTicket 工单系统教程

要访问 osTicket 控制面板,请在 Web 浏览器中输入 URL http://osticket.example.com/scp。你应该会看到 osTicket 登录页面。

在 Ubuntu 22.04 上通过 Apache 部署 osTicket 工单系统教程

输入你的管理员用户名和密码,然后点击 Login(登录)按钮。你应该在以下屏幕上看到 osTicket 仪表盘。

在 Ubuntu 22.04 上通过 Apache 部署 osTicket 工单系统教程

你也可以使用 URL http://osticket.example.com 访问 osTicket 默认页面。

使用 Let's Encrypt SSL 保护 osTicket

要使用 Let's Encrypt SSL 保护你的网站,你需要在服务器上安装 certbot 软件包。

首先,使用以下命令安装 Snap 软件包管理器:

apt install snapd

接下来,将 Snap 软件包更新到最新版本:

snap install core
snap refresh core

接下来,使用以下命令安装 certbot 软件包:

snap install --classic certbot

接下来,为 Certbot 二进制文件创建指向系统位置的符号链接:

ln -s /snap/bin/certbot /usr/bin/certbot

接下来,运行以下命令下载并安装 Let's Encrypt SSL 证书:

certbot --apache -d osticket.example.com

系统会要求你提供邮箱地址并接受服务条款:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 
[email protected]


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

输入 Y 并按 Enter 键为你的域名下载并安装 SSL 证书:

Account registered.
Requesting a certificate for osticket.example.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/osticket.example.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/osticket.example.com/privkey.pem
This certificate expires on 2023-03-22.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for osticket.example.com to /etc/apache2/sites-enable/osticket.conf
Congratulations! You have successfully enabled HTTPS on https://osticket.example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

结论

在本文中,我们介绍了如何在 Ubuntu 22.04 服务器上使用 Apache 安装 osTicket。你现在可以在你的组织中部署 osTicket,以扩展并简化你的客户服务,并大幅改善客户体验。