Installing nuBuilder Forte

I decided to try out nuBuilder Forte as I needed a simple way to design forms and reports for a database for another project I’m working on. The first problem was to find out how to test it. I went to the nuBuilder website, had a quick look around, thought this looks good but where is the download page? Most websites for products have a download page with instructions on how to set it up but this site was lacking that page. Eventually, after a lot of searching I found a wiki page that states:

The trickiest thing with nuBuilder is its initial installation.

https://wiki.nubuilder.net/nubuilderforte/index.php/Test_Environment

Great news! NOT!!!!! There are two links on that page, one to a YouTube video that tells you how to set up nuBuilder on a hosting website that you have to pay for. As I just wanted to see if it do what I wanted, I wasn’t going to pay for a hosted site that I might use for a day or two and then never use again. The other link was to a post on the nuBuilder forum by bmullan that explains how to install nuBuilder on a virtual machine (VM) or LXD container. I chose to go down the LXD route as it was simplest to setup on my host PC, I had never tried out LXD containers and wanted to compare with docker that I have used many times over the years.

So I followed bmullan’s guide but for a LXD newbie like me, I had to find out how to install LXD and set it up. After more searching, I found this blog post that helped fill in the gaps. To make it easy for anyone else wanting to test nuBuilder, I have documented all the steps I took to get it working in an LXD container.

Installing nuBuilder in an LXD container

Install LXD

This is fairly straightforward if you just follow the blog post without thinking too hard. First install LXD using:

sudo snap install lxd

Once this has been done, you need to log out and in again as you have been added to the lxd group that allows you use the lxd/lxc commands with out sudo. Then initialise LDX using:

lxd init

There are a lot of options that you can play with but accepting every default worked for me.

Create the container:

$ lxc launch ubuntu:b nubuilder

After a minute or so, the container is running. You can check this using:

$ lxc list
+-----------+---------+---------------------+-----------------------------------------------+-----------+-----------+
|   NAME    |  STATE  |       IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |
+-----------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| nubuilder | RUNNING | 10.51.251.63 (eth0) | fd42:cc54:c9ee:527e:216:3eff:fe16:164c (eth0) | CONTAINER | 0         |
+-----------+---------+---------------------+-----------------------------------------------+-----------+-----------+

This container has a basic image of Ubuntu so now we need to add some packages to make it all work. Get a root Bash prompt on the container using:

$ lxc exec nubuilder bash
root@nubuilder:~#

Now install the packages that are needed to to support nuBuilder: MySQL for the database, Apache2 for the web server and PHP for scripting. This is often referred to as a LAMP (Linux, Apache, MySQL, PHP) stack. At the prompt enter:

# apt update
# apt install -y mysql-server apache2 php php-mysql unzip libapache2-mod-php php-mbstring

Installing the nuBuilder code

This is really simple. Just enter the following:

# cd /var/www/html/
# rm index.html
# git clone https://github.com/steven-copley/nubuilder4.git
# mv ./nubuilder4/* . 

Configuring the MySQL database

I started by securing the MySQL database. This step is probably not needed if you just want to test nuBuilder on a local machine but this is what I did.

# mysql_secure_installation
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

Please set the password for root here.
New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database…
Success.

Removing privileges on test database…
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

One tip about password choice. I originally used an auto generated password with too many special characters in it and nuBuilder wouldn’t start properly (see troubleshooting section for details). I created a new password which was basically letters and numbers with a couple of standard symbols thrown in and this worked fine.

The next thing to do was to create a database for nuBuilder to use.

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE nubuilder4;
Query OK, 1 row affected (0.01 sec)
mysql> quit
Bye 

Now load the nubuilder4 database with data.

# cd /var/www/html/
# mysql -u root -p nubuilder4 < ./nubuilder4.sql 

Use your editor of choice to add the MySQL root password to the file /var/www/html/nuconfig.php.

Finally, and this is important, restart the container using # reboot. This allows all the changes you have made to run properly. I didn’t do this and wasted a fair bit of time before I re-read the instructions and rebooted.

Check that the nuBuilder is working

At this stage, it is worth checking that nuBuilder can talk to the MySQL database. The following block shows the command I used in the container and the expected output.

# wget http://127.0.0.1/ -O -
--2020-04-10 12:14:15--  http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5721 (5.6K) [text/html]
Saving to: ‘STDOUT’
...
!DOCTYPE html>
<html id="nuhtml" onclick="nuClick(event)">
<head>
<title>nuBuilder 4</title>
...
2020-04-10 12:14:16 (666 MB/s) - written to stdout [5721/5721]

Note: each ellipsis ... show where lots of text has been cut out.

Connecting the container to the host PC

The final step is to connect the Apache web server on port 80 in the container to the host PC on port 80. First check if your host PC is using port 80. This is what my PC showed:

$ sudo netstat -tpln | grep 80
tcp6 0 0 fe80::4a39:2ddc:e:49152 :::* LISTEN 7933/upplay
tcp6 0 0 fe80::80e:7bff:fef6::53 :::* LISTEN 7472/dnsmasq 

Nothing on port 80. Now you can create an LXD proxy device that connects port 80 of the Apache webserver in the container to port 80 of the host using this command:

lxc config device add nubuilder nubuilder80 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80 

I used the same wget command that I used on the host to download index.php and it worked. I then tested it on the browser by going to the URL: http://127.0.0.1/. SUCCESS!!! I could see the login page for nuBuilder so I logged in as globeadmin. There was a problem! According to the bullman’s guide, there should be two tabs on the main screen: setup and builders. There were no tabs at all. So following the final steps of bullman’s guide, I appended the following lines to /etc/alternatives/my.cnf

[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]
port=3306
socket=/tmp/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
sql-mode=NO_ENGINE_SUBSTITUTION

[mysqldump]
quick 

Rebooted the container and it finally worked!!!

Now to find out if nuBuilder really is as easy to use as it claims to be but that will be for another time (maybe).

Troubleshooting

Password problems

When I finally managed to connect to the nubuilder container, I received an error message. I viewed the Apache web server log files to find out what was going on.

# less /var/log/apache2/error.log
…
[Thu Apr 09 16:52:44.027971 2020] [php7:error] [pid 456] [client 127.0.0.1:35478] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' in /var/www/html/nudatabase.php:12\n
Stack trace:\n
0 /var/www/html/nudatabase.php(12): PDO->__construct('mysql:host=127….', 'root', '', Array)\n
1 /var/www/html/nuchoosesetup.php(21): require_once('/var/www/html/n…')\n
2 /var/www/html/index.php(3): require_once('/var/www/html/n…')\n
3 {main}\n thrown in /var/www/html/nudatabase.php on line 12 

I realised that this was something to do with the password I was using. I could log in to the MySQL database from the Bash prompt with no problems but nuBuilder didn’t work. I changed my password to something with less special characters in it and it worked. For reference, the password contained the following characters special characters

 (`)[;,!

My guess is that there is a script in nubuilder that uses the MySQL root password and one of the characters I used caused it to misbehave, possibly truncating the password.

LXD network problems

I spent a fair bit of time chasing down LXD network problems when I added a proxy device to expose port 80. I found this discussion on the LXC forum very useful as it goes though the steps needed to diagnose network issues.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s