Blogging without javascript

Install WHMCS from the scratch

Have you ever heard of WHMCS? Yeah, me neither... Got to know it very recently. But I'm here not to explain how to install and configure it using a docker container.

Nowadays when you think about blog then WordPress is the first tool that comes to mind. WHMCS is the same thing, but for web hosting businesses.

In this tutorial I'm gonna teach you how to install this tool using docker.

Unzip whmcs_8.1.3_full.zip

Considering you already have the zip file in your hands, just unzip it somewhere isolated.

unzip whmcs_8.1.3_full.zip
ls -F
EULA.txt  README.txt  whmcs/  whmcs_8.1.3_full.zip

Contact me via email to get a copy of the code.

The docker container

Assuming you already have the docker command installed. Let's just create a container running the image php:5-alpine.

The commands below assumes you have another container running a mysql database. Considering we will be using version 8.1.3 here is the table of databases supported by each version of WHMCS: https://docs.whmcs.com/System_Environment_Guide#Database.

Creating the container

sudo docker run \
    -d \
    -w /var/www \
    -v `pwd`:/var/www \
    -p 80:80 \
    --name whmcs \
    php:5-alpine \
    sh -c 'while :; do sleep 1; done'

You'll have to configure the correct port in order to make it all work.

The command above just creates a container named whmcs running the php:5-alpine image. Now let's connect it to the same network database's container is running on.

Connecting the container to the same network the database is in

sudo docker network \
    connect \
    whmcs-mysql-network \
    whmcs

The command above connects the container whmcs to a ficticious network named whmcs-mysql-network to which some whmcs-mysql container is connected and running mysql on port 3306. It's configurations are not important at the moment as long as it is compatible.

Log into the container

sudo docker exec -ti whmcs sh

Once into the docker environment we need to configure everything as if we had installed alpine.

Execute commands in the docker container

First we need to install the nginx server (mandatory), the vim editor and the mysql-client, just in case we need them.

apk update
apk add nginx vim mysql-client

Then we need to create the configuration file for the nginx server.

mkdir -p /run/nginx/
cat <<'EOF' -> /etc/nginx/conf.d/default.conf
server {
  listen 80;
  listen [::]:80;
  server_name localhost;
  root /var/www;
  index index.html index.htm index.php;
  charset utf-8;
  error_page 404 /index.php;

  location / { 
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    fastcgi_pass localhost:9000;
    fastcgi_pass_header "x-accel-buffering";
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    fastcgi_read_timeout 3000;
    proxy_read_timeout 3000;
    proxy_connect_timeout 3000;
    proxy_send_timeout 3000;
    send_timeout 3000;
    include fastcgi_params;
  }
}
EOF

After that we will install all available php extensions. Some of these might not work for you. I'm just being cautious. Better safe than sorry.

apk add php7 php7-intl php7-openssl php7-dba php7-sqlite3 php7-pear php7-tokenizer php7-phpdbg php7-litespeed php7-gmp php7-pdo_mysql php7-sodium php7-pcntl php7-common php7-oauth php7-xsl php7-fpm php7-gmagick php7-imagick
apk add php7-mysqlnd php7-enchant php7-pspell php7-redis php7-snmp php7-doc php7-fileinfo php7-mbstring php7-dev php7-pear-mail_mime php7-xmlrpc php7-xmlreader php7-pear-mdb2_driver_mysql php7-pdo_sqlite php7-pear-auth_sasl2
apk add php7-exif php7-recode php7-opcache php7-ldap php7-posix php7-pear-net_socket php7-session php7-gd php7-gettext php7-mailparse php7-json php7-xml php7-mongodb php7 php7-iconv php7-sysvshm php7-curl php7-shmop php7-odbc php7-phar
apk add php7-pdo_pgsql php7-imap php7-pear-mdb2_driver_pgsql php7-pdo_dblib php7-pgsql php7-pdo_odbc php7-xdebug php7-zip php7-apache2 php7-cgi php7-ctype php7-amqp php7-mcrypt php7-wddx php7-pear-net_smtp php7-bcmath php7-calendar
apk add php7-tidy php7-dom php7-sockets php7-zmq php7-event php7-memcached php7-yaml php7-soap php7-apcu php7-sysvmsg php7-imagick-dev php7-embed php7-ssh2 php7-ftp php7-sysvsem php7-pear-net_idna2 php7-pdo php7-pear-auth_sasl php7-bz2
apk add php7-mysqli php7-pear-net_smtp-doc php7-simplexml php7-xmlwriter

Then we need to download the ioncube module and configure it to be available for this build of PHP.

cd ~
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xzf ioncube_loaders_lin_x86-64.tar.gz
cp ~/ioncube/*[0-9].so /usr/lib/php7/modules/
echo 'zend_extension = /usr/lib/php7/modules/ioncube_loader_lin_7.2.so' > /etc/php7/conf.d/00-ioncube.ini

If you need the tarball used in this example send me an email.

Finally we just need to run the nginx server and fastcgi process manager (fpm).

nginx -c /etc/nginx/nginx.conf &
php-fpm7

Pay attention to the output so that no errors are shown.

Just to be sure let's create the whmcs database.

echo 'create database whmcs' | mysql -h whmcs-mysql -u root -p && echo Created
Enter password: *************
Created

Change the above user (root) to whichever can create that database.

Configuring the frontend

Once everything is set it is expected that the whmcs HOST folder be inside of the /var/www/ CONTAINER folder, therefore being accessed via /var/www/whmcs/ inside of the CONTAINER.

It is important to notice that the configuration.php file MUST NOT be present and the /var/www/whmcs/install/ folder MUST be present.

To make everything easier again just run this command, inside the CONTAINER, to avoid problems.

chown -R nobody.nobody /var/www/
chmod -R 777 /var/www/

After that, in the HOST, open up your browser and go to http://localhost/whmcs/install/install.php.

https://gitlab.com/azgher/test/uploads/e00d7e1488d5bf7a9b3be25bfc6b6f8f/Screenshot_from_2022-02-20_15-22-08.png

Click "I AGREE".


If everything goes right you should see the page below.

https://gitlab.com/azgher/test/uploads/a4c7b2c52e8f3bac738b61b8dc468123/Screenshot_from_2022-02-20_15-33-16.png

Click "Begin Installation".


Then you'll have to provide the database information. Notice that the Database Host just points to the whmcs-mysql container. This works because both containers are in the same network, therefore they can communicate with eachother by hostname. The License Key information is not important.

https://gitlab.com/azgher/test/uploads/fd8bc02987fe180acc0b015b034562f0/Screenshot_from_2022-02-20_15-36-36.png

This process will take a while because WHMCS will create about 159 tables inside of that whmcs database we created earlier.


Now you just create the first admin user. Anything will go. I just typed admin for everything (except email).

https://gitlab.com/azgher/test/uploads/d2a07ee34b013d80eb3f149bcdbdc3b4/Screenshot_from_2022-02-20_15-42-50.png


Once everything is set you can start using WHMCS.

https://gitlab.com/azgher/test/uploads/77d48bbac846244be7c53d3fe2647823/Screenshot_from_2022-02-20_15-44-27.png

The admin page

In the HOST machine open up your browser and go to http://localhost/whmcs/admin/, an interesting alert will pop.

https://gitlab.com/azgher/test/uploads/e3b0a2aa55b19274301afc317d9f83c2/Screenshot_from_2022-02-20_15-46-45.png

The instructions are simple but I advise you to just rename the install folder.

Inside the CONTAINER run this command.

mv /var/www/whmcs/install/ /var/www/whmcs/install-old/

After that just reload the page (http://localhost/whmcs/admin/).


Just login using the following credentials:

USERNAME admin
PASSWORD admin

https://gitlab.com/azgher/test/uploads/a3083fe6f17ff215f960eb1279d74b80/Screenshot_from_2022-02-20_15-50-04.png


Close the annoying window that shows up and there we go!

https://gitlab.com/azgher/test/uploads/017376a97bae0f55855a9c39a8ffb1d1/Screenshot_from_2022-02-20_15-52-13.png

Now you can... do whatever people do using this thing... I guess...

Documentation and dev sources

dptoledo@pm.me

#docker #ecommerce #fpm #host #mysql #network #nginx #php #whmcs