How to install WHMCS 7.7.1 on CentOS 7 Linux

As you may know, WHMCS is the leading web hosting management and billing software that automates all aspects of your business from billing, provisioning, domain reselling and etc. In this article, we are going to install WHMCS 7.7.1 on CentOS 7.6.
We assume you have a valid WHMCS license and have downloaded its package from WHMCS download area.

Here are our environment OS and software versions:

OS: Centos 7.6 on VMware
WHMCS: 7.7.1
PHP: 7.2
Database: Mariadb 10.3
Web server: httpd 2.4
Firewall: CSF

here we start from a fresh minimal CentOS 7.6 installation.

1- Initial CentOS setup

Set correct time and date. here we use “America/New_York”:

# timedatectl set-timezone America/New_York

Change default root password:

# passwd

Set SELinux to permissive mode by editing /etc/selinux/config:

# vim /etc/selinux/config
SELINUX=permissive

Also to apply it immediately run:

# setenforce 0

Install EPEL repository:

# yum install epel-release

Update OS:

# yum update

The NETWORKING variable must be set to yes if you want networking to start at boot time:

# vim /etc/sysconfig/network
NETWORKING=yes

if you dont have wifi, disable WIFI network. otherwise skip it:

# nmcli radio all off

here we disable kdump service. you can skip it if you want:

# systemctl disable kdump

because we run our OS on VMware, we install open-vm-tools. if you run your OS on a physical machine you can skip it:

# yum install open-vm-tools

2- Optional install CSF

For stronger security we install CSF. you can skip it or refer to How to install CSF on CentOS 7 Linux.

3- Optional setup LVM

In this installation, we decided use lvm and move /var partition to another volume. So if you dont plan to do this, skip it, otherwise you can refer to article How to create LVM with four disks on CentOS 7 linux.

4- Install PHP 7 and Apache

Install remi repository for PHP 7 installation:

# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Install yum-utils:

# yum install yum-utils

Enable remi repository:

# yum-config-manager --enable remi-php72

then install PHP 7:

# yum install php php-mbstring php-pear php72-php-pdo.x86_64 php-pdo.x86_64 php-mysql.x86_64 php-ioncube-loader.x86_64 php-curl curl php-soap.x86_64 php72-php-soap.x86_64 php-gd.x86_64 php72-php-gd.x86_64

Edit php.ini and set options like the following:

# vim /etc/php.ini
date.timezone = "America/New_York"
memory_limit = 1024M
extension=pdo.so
extension=pdo_mysql.so

Install apache and start it:

# yum install httpd
# systemctl enable httpd
# systemctl start httpd

5- Install Mariadb 10.3 and setup database

Install MariaDb. refere to Database replication with mariadb on centos 7 linux.

Login to mariadb and create required user and database:

# mysql –u root –p
# CREATE USER 'your user'@'localhost' IDENTIFIED BY 'your password';
# GRANT ALL PRIVILEGES ON *.* TO 'your user'@'localhost';
# Create database 'your database name';

6- Install WHMCS 7.7.1

Extract whmcs installation files to /var/www/html and change owner of files to apache:

chown -r apache:apache /var/www/html/*

Create new configuration.php file and change permission to 777:

# mv /var/www/html/configuration.php.new /var/www/html/configuration.php
# chmod 777 /var/www/html/configuration.php

In Google Chrome or Firefox navigate to your server IP address and install WHMCS. follow the instruction and filll required fiels. after installation, delete install folder from /var/www/html/

# rm -rf /var/www/html/install/

To improve security, move downloads, template_c and attachments directory from /var/www/html/ to /var/www/ :

# mv /var/www/html/attachments/ /var/www/attachments/
# mv /var/www/html/downloads/ /var/www/downloads/
# mv /var/www/html/templates_c/ /var/www/templates_c/

Change owner and permission of above directory:

# chmod 777 /var/www/attachments/ /var/www/downloads/ /var/www/templates_c/
# chown apache:apache /var/www/attachments/ /var/www/downloads/ /var/www/templates_c/

add the following lines to /var/www/html/configuration.php

$mysql_charset = "utf8";
$display_errors="off";
$templates_compiledir = "/var/www/templates_c/";
$attachments_dir = "/var/www/attachments/";
$downloads_dir = "/var/www/downloads/";

add the following line to /etc/crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
*/5 * * * * root /usr/bin/php -q /var/www/html/crons/cron.php

change /var/www/html/configuration permission to 600:

chmod 600 /var/www/html/configuration