How to migrate osTicket to a new Host machine

Fonte: ARDITI - WIKI
Saltar para a navegação Saltar para a pesquisa

Currently, our support application is in the server Folhado among many web servers. This server is running PHP 7.4, which prevents us from updating the support application (osTicket) to the newer version since it requires PHP 8.1.

For this reason, we prepared the machine Gandalf to be our support server. This machine will contain only the osTicket and its database.

Note: This is not just a migration but also an update since we are going to the newer version of the osTicket.

Preparing everything

Gandalf is a machine that has public access. To prepare for the application, we installed the following software:

Maintenance Mode

Before starting, you must put your current osTicket in maintenance mode. This mode will prevent changes to the database and osTicket from fetching new tickets to the email.

For this:

  1. Log into osTicket as an Agent with administrator privileges.
  2. Go to settings under General Settings you will have Helpdesk Status select offline and save changes.
  3. Go to Email > Settings and under Incoming Emails: remove the selection from Enabled

Enabling maintenance mode in osTicket Disabling email fetching

Getting the Database

Since we want to maintain the data from the old server to the new one, we will have to backup the data. You can achieve this through PHPMyAdmin or using CLI on your server. We are going with the second option as we also need the configuration file from the old server.

  1. ssh into the old server.
  2. Navigate to the /tmp folder.
  3. Create a new folder and navigate to it mkdir osTicket_Backup && cd osTicket_Backup .
  4. Copy the config file sudo cp /var/www/support.arditi.pt/htdocs/include/ost-config.php ..
  5. And dump the database sudo mysqldump -p arditi_support > osTicket.sql.
  6. zip the folder cd .. && zip -r osTicket_Backup.zip osTicket_Backup.

Now you have everything you need from the old server. Go ahead and send it to the new server: scp osTicket_Backup.zip <username>@<target_ip>:/tmp

Downloading the new version of osTicket

  1. ssh into the new server
  2. navigate to tmp cd /tmp
  3. download the lastest version of osTicket git clone https://github.com/osTicket/osTicket

Downloading the lastest plugins required

Start the installation

  1. Navigate to the downloaded osTicket cd /tmp/osTicket
  2. Use the manage.php to move osTicket to its target folder sudo php manage.php deploy --setup /var/www/osTicket/htdocs/
  3. Now you need to install the missing PHP libs present in your site: sudo apt-get install php-mysqli php-gd php-imap php-xml php-mbstring php-intl php-apcu php-ldap
  4. restart apache sudo service apache2 restart

At this point, if you navigate to your webpage, you should encounter something similar:

All packages required to run osTicket

Create a database

Before going any further, we need to create a database and a user for osTicket. To save time, you can make everything with the same credentials as on the first server. However, if you do wish to change, this is the time.

  1. Access mysql sudo mysql -p
  2. Create a new database CREATE DATABASE osTicket;
  3. Create a new user: CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
  4. Grant permissions to the osTicket database: GRANT ALL PRIVILEGES ON osTicket.* TO 'username'@'localhost';
  5. Flush the priviledges: FLUSH PRIVILEGES;
  6. Done exit;

Uploading the database

To confirm that the user is working properly, use it to upload the database: sudo mysql -u <user> -p osTicket < /tmp/osTicket_Backup/osTicket.sql

Suppose everything went right, login into the database and disable force_https. Otherwise, you won't be able to load the page while the server is not ready:

  1. sudo mysql -u <user> -p
  2. USE osTicket
  3. UPDATE ost_config SET `value`="" WHERE `key`='force_https';
  4. exit

Reconfiguring Accesses

If you used the same name for the user and the database and kept the same password, skip this step. You need to edit the ost_config.php file if you have changed something. vim /tmp/osTicket_Backup/ost-config.php Edit the following variables according to your database information:

# Mysql Login info
define('DBTYPE','mysql');
define('DBHOST','localhost');
define('DBNAME','<databasename>');
define('DBUSER','<databaseuser>');
define('DBPASS','<database password>');

Finishing the install

Move the ost-config.php file to its final location: sudo cp /tmp/osTicket_Backup/ost-config.php /var/www/osTicket/htdocs/include/

Login into your osTicket, <server_ip/hostname>/scp You need to use a local user since this is more or less a fresh install. There are no LDAP users at the moment.

Recover local user

To find a user follow these steps:

  1. sudo mysql -u <user created> -p
  2. USE <database name>;
  3. SELECT staff_id, username, firstname, lastname, passwd FROM ost_staff;

If you see a user without a NULL password, you can edit that password and use it to log in. UPDATE ost_staff SET `passwd`='40be4e59b9a2a2b5dffb918c0e86b3d7' WHERE `username`='<username>';

Note: 40be4e59b9a2a2b5dffb918c0e86b3d7 translates to "welcome".

Upgrading

If everything went smooth until this point, it is time to upgrade. Please, login and follow the upgrading instructions from osTicket. Once you finish, remove the setup folder and give the ownership to the webserver:

Finishing the core installation

With the upgrade complete, is time to remove the setup folder: sudo rm -r /var/www/osTicket/htdocs/setup.

Also give the ownership of every folder from osTicket to the webserver: sudo chown -R www-data:www-data /var/www/osTicket/htdocs/*

Remember to go back to the database and enable force_https: UPDATE ost_config SET `value`='1' WHERE `key`='force_https';

Fetching Email

Now that everything is ready and working. You must create a cron job to fetch the emails from your mail server.

Follow these steps:

  1. sudo crontab -e
  2. At the end of the file add: */5 * * * * /usr/bin/php -q /var/www/<osTicket Directory>api/cron.php

Installing Plugins

Go to osTicket download page and click on plugins. Upload them to your server and move them to the plugins folder. Then follow the instructions on the webpage