How to Install osTicket on FreeBSD 12
osTicket is an open-source customer support ticketing system. osTicket source code is publicly hosted on Github. In this tutorial, you will learn how to install and configure osTicket on FreeBSD 12.
Requirements
- HTTP server running Nginx or Apache. This guide uses Nginx.
- PHP version 5.6 to 7.2, 7.2 is recommended
mysqli
,gd
,gettext
,imap
,json
,mbstring
, andxml
extension for PHP- MySQL database version 5.0 or greater or MariaDB equivalent
Before you begin
Check the FreeBSD version.
uname -ro
# FreeBSD 12.0-RELEASE
Ensure that your FreeBSD system is up to date.
freebsd-update fetch install
pkg update && pkg upgrade -y
Install the necessary packages.
pkg install -y sudo vim unzip curl wget bash socat git
Create a new user account with your preferred username.
adduser
# Username: johndoe
# Full name: John Doe
# Uid (Leave empty for default): <Enter>
# Login group [johndoe]: <Enter>
# Login group is johndoe. Invite johndoe into other groups? []: wheel
# Login class [default]: <Enter>
# Shell (sh csh tcsh nologin) [sh]: bash
# Home directory [/home/johndoe]: <Enter>
# Home directory permissions (Leave empty for default): <Enter>
# Use password-based authentication? [yes]: <Enter>
# Use an empty password? (yes/no) [no]: <Enter>
# Use a random password? (yes/no) [no]: <Enter>
# Enter password: your_secure_password
# Enter password again: your_secure_password
# Lock out the account after creation? [no]: <Enter>
# OK? (yes/no): yes
# Add another user? (yes/no): no
# Goodbye!
Run the visudo
command and uncomment the %wheel ALL=(ALL) ALL
line, to allow members of the wheel
group to execute any command.
visudo
# Uncomment by removing hash (#) sign
# %wheel ALL=(ALL) ALL
Now, switch to your newly created user with su
.
su - johndoe
NOTE: Replace johndoe
with your username.
Set up the timezone.
sudo tzsetup
Install PHP
Install PHP, as well as the necessary PHP extensions.
sudo pkg install -y php72 php72-mbstring php72-tokenizer php72-pdo php72-pdo_mysql php72-openssl php72-hash php72-json php72-phar php72-filter php72-zlib php72-dom php72-xml php72-xmlwriter php72-xmlreader php72-curl php72-session php72-ctype php72-iconv php72-gd php72-simplexml php72-zip php72-filter php72-tokenizer php72-calendar php72-fileinfo php72-intl php72-phar php72-soap php72-xmlrpc php72-opcache php72-mysqli php72-bcmath php72-gmp php72-exif php72-imap php72-pecl-APCu
Check the version.
php -v
# PHP 7.2.9 (cli) (built: Sep 7 2019 01:12:47) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.9, Copyright (c) 1999-2018, by Zend Technologies
Check installed PHP extensions.
php -m
# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .
Soft-link php.ini-production
to php.ini
.
sudo ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Enable and start PHP-FPM.
sudo sysrc php_fpm_enable=yes
sudo service php-fpm start
Install MariaDB
Install MariaDB.
sudo pkg install -y mariadb102-client mariadb102-server
Check the version.
mysql --version
# mysql Ver 15.1 Distrib 10.2.25-MariaDB, for FreeBSD12.0 (amd64) using readline 5.1
Start and enable MariaDB.
sudo sysrc mysql_enable="yes"
sudo service mysql-server start
Run the mysql_secure_installation
script to improve the security of your MariaDB installation.
sudo mysql_secure_installation
Log into MariaDB as the root user.
sudo mysql -u root -p
# Enter password:
Create a new MariaDB database and user and remember the credentials.
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;
Install Nginx
Install Nginx.
sudo pkg install -y nginx
Check the version.
nginx -v
# nginx version: nginx/1.16.1
Enable and start Nginx.
sudo sysrc nginx_enable=yes
sudo service nginx start
Configure Nginx for use with the osTicket.
sudo vim /usr/local/etc/nginx/osticket.conf
And populate the file with the below config.
server {
listen 80;
server_name example.com;
root /usr/local/www/osticket/upload;
index index.php index.html;
set $path_info "";
location ~ /include {
deny all;
return 403;
}
if ($request_uri ~ "^/api(/[^\?]+)") {
set $path_info $1;
}
location ~ ^/api/(?:tickets|tasks).*$ {
try_files $uri $uri/ /api/http.php?$query_string;
}
if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
set $path_info $1;
}
if ($request_uri ~ "^/.*\.php(/[^\?]+)") {
set $path_info $1;
}
location ~ ^/scp/ajax.php/.*$ {
try_files $uri $uri/ /scp/ajax.php?$query_string;
}
location ~ ^/ajax.php/.*$ {
try_files $uri $uri/ /ajax.php?$query_string;
}
location / {
try_files $uri $uri/ index.php;
}
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param PATH_INFO $path_info;
fastcgi_pass 127.0.0.1:9000;
}
}
Save the file and exit with Colon+W+Q.
Now we need to include osticket.conf
in the main nginx.conf
file.
Run sudo vim /usr/local/etc/nginx/nginx.conf
and add the following line to the http {}
block.
include osticket.conf;
Test the configuration.
sudo nginx -t
Reload Nginx.
sudo service nginx restart
Install osTicket
Create a document root directory.
sudo mkdir -p /usr/local/www/osticket
Change ownership of the /usr/local/www/osticket
directory to johndoe
.
sudo chown -R johndoe:johndoe /usr/local/www/osticket
Navigate to the document root folder.
cd /usr/local/www/osticket
Download and unzip the latest release of osTicket.
wget https://github.com/osTicket/osTicket/releases/download/v1.14.1/osTicket-v1.14.1.zip
unzip osTicket-v1.14.1.zip
rm osTicket-v1.14.1.zip
Copy the sample config file.
sudo cp upload/include/ost-sampleconfig.php upload/include/ost-config.php
Change ownership of the /usr/local/www/osticket
directory to www
.
sudo chown -R www:www /usr/local/www/osticket
Once everything is configured, it's time to access the osTicket web installation wizard. Open your site in a web browser and follow the instructions on the screen to finish the installation.
After installation, delete the setup
directory for security.
sudo rm -rf upload/setup
sudo chmod 0644 upload/include/ost-config.php