How to Install MantisBT 2.5 on CentOS 7

Updated on November 30, 2017
How to Install MantisBT 2.5 on CentOS 7 header image

MantisBT, or Mantis Bug Tracker, is an open source issue tracker written in PHP. MantisBT is finely balanced between ease of use and functionality, providing great user experiences to all members in a development team.

Prerequisites

Step 1: Setup a LAMP stack

In order to serve MantisBT, setup an up to date LAMP stack which consists of the following.

  • CentOS 7
  • Apache 2.4
  • MariaDB 10.2
  • PHP 7.1

Since setting up a LAMP stack has been covered in multiple Vultr tutorials, I will not detail the process herein but provide you the command line history for your reference.

# Install Apache 2.4
sudo yum install httpd -y
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
sudo systemctl start httpd.service
sudo systemctl enable httpd.service

# Install MariaDB 10.2
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
sudo yum install MariaDB-server MariaDB-client -y
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

# Secure MariaDB 10.2
sudo /usr/bin/mysql_secure_installation
# When prompted, answer questions as below:
# - Enter current password for root (enter for none): Just press the Enter button
# - Set root password? [Y/n]: Y
# - New password: your-MariaDB-root-password
# - Re-enter new password: your-MariaDB-root-password
# - 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

# Create a MariaDB database for MantisBT
mysql -u root -p
# For security purposes, be sure to replace "mantisbt", "mantisbtuser", and "yourpassword" with your own ones. 
CREATE DATABASE mantisbt;
CREATE USER 'mantisbtuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON mantisbt.* TO 'mantisbtuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

# Install PHP 7.1
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install -y php71w php71w-mysqlnd php71w-common php71w-cli php71w-xml php71w-mbstring php71w-gd php71w-mcrypt php71w-opcache php71w-imap php71w-process php71w-intl
sudo cp /etc/php.ini /etc/php.ini.bak
sudo sed -i 's#;date.timezone =#date.timezone = America/Los_Angeles#' /etc/php.ini

# Configure firewall rules
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Step 2: Prepare MantisBT program files

Download and decompress the MantisBT archive.

cd
wget https://downloads.sourceforge.net/project/mantisbt/mantis-stable/2.5.1/mantisbt-2.5.1.zip
sudo yum install -y unzip
unzip mantisbt-2.5.1.zip

Move the MantisBT files to a proper location and then grant proper permissions to them.

sudo mv ~/mantisbt-2.5.1 /opt
sudo ln -s /opt/mantisbt-2.5.1 /var/www/html/mantisbt
sudo chown -R apache:apache /opt/mantisbt-2.5.1

Step 3: Setup an Apache virtual host for MantisBT

Before you can properly run MantisBT, you need to setup an Apache virtual host for MantisBT. Just copy the whole code segment below into your SSH terminal and then press Enter.

Note: Remember to modify the values of ServerAdmin, ServerName, and ServerAlias on your machine accordingly.

cat <<EOF | sudo tee -a /etc/httpd/conf.d/mantisbt.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/mantisbt/
ServerName mantisbt.example.com
ServerAlias www.mantisbt.example.com
<Directory /var/www/html/mantisbt/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/mantisbt.example.com-error_log
CustomLog /var/log/httpd/mantisbt.example.com-access_log common
</VirtualHost>
EOF

Restart Apache in order to enable all of your changes.

sudo systemctl restart httpd.service

Step 4: Continue the installation in the MantisBT web installation wizard

Point your favorite web browser to your server's IP, and you will be brought into the MantisBT web installation wizard interface.

In the Checking Installation section, make sure that every item is GOOD.

In the Installation Options section, input the MariaDB database credentials as follows, leave other fields untouched, and then click the Install/Upgrade Database button to move on.

  • Username (for Database): mantisbtuser
  • Password (for Database): yourpassword
  • Database name (for Database): mantisbt

On the next stage click the Continue link at the bottom to finish the installation and switch to the log-in page.

On the log-in page, use the default admin username administrator and the default password root to log in. For security purposes, you need to modify the default password immediately.

After confirming that MantisBT is up and running properly, you need to delete the MantisBT root directory in order to prevent unauthorized access.

sudo rm -rf /var/www/html/mantisbt/admin

If necessary, you can customize MantisBT by editing the file /var/www/html/mantisbt/config/config_inc.php.