Creating Lucee development environment with CentOS 7 in VirtualBox
March 12, 2018

For development with Lucee, I would recommend having VirtualBox setup. Server OS like Ubuntu Server or CentOS running in virtual machine could access external source code (*.cfm files) from Host system (in my case, Windows 10).

Work scenario is that work files are stored on Host (Windows) machine, where they could be edited using handy Windows tools like VS Code, IntelliJ IDEA or CFEclipse. Git Repository can be managed with visual tools like GitKraken or GitHub Desktop or SourceTree. But processing of code by Apache and Lucee will be performed inside VirtualBox Virtual Machine.

Advantages of this approach are that you can have separate server installations on one host machine, isolate problems to virtual machine, and emulate performance of real server (VPS or cloud are usually has less resources that development machines, but limiting VirtualBox to 1 CPU and 2-3GB of RAM is close to real setup).

Right to the business:

  • Download CentOS from official site (I prefer Torrent download).
  • Create new Virtual machine with 1CPU and 2-3GB of RAM, and add 2 network interfaces: NAT and Host-only Adapter.
  • Insert ISO file into VirtualBox drive and start machine. It will boot up CentOS, and installer will guide you through setup process. There's not much to describe at this point, installer make things quite obvious.
  • After installation, login to CentOS as root.
  • Let's disable SELinux, it will make things easier. Edit /etc/sysconfig/selinux file, set
SELINUX=disabled
  • Restart machine
  • After restart let's enable network interfaces to have connectivity:
ifconfig

ifup enp0s8

ifup enp0s3
  • We would need network interfaces up upon startup. In /etc/sysconfig/network-scripts/ifcfg-enp0s3 make sure that
ONBOOT=yes
  • To be able to connect via SSH, we would need to enable SSH daemon and disable firewall. Use command
ntsysv

to enable/disable sshd and firewall daemon.

  • Allow VirtualBox to use DNS, changes to be made in your Host system (Windows). Put down Virtual Machine and in VirtualBox directory run command:
PS C:\Program Files\Oracle\VirtualBox> .\VBoxManage modifyvm "centos" --natdnshostresolver1 on
  • To be sure system is up-to-date, run
yum update
  • Now install MySQL (MariaDB). There's many tutorials online: one, two, three. Main idea is to add new repository and then install with Yum.
cd /etc/yum.repos.d/

touch MariaDB.repo
nano MariaDB.repo
  • Edit the file:
# MariaDB 10.2 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
  • Then install server and client
yum install MariaDB-server MariaDB-client
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
/usr/bin/mysql_secure_installation
  • Allow external access to all databases - this will allow to connect with Windows SQL tools
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
  • In Centos 7 you can have OpenJDK installed using yum, but to install Oracle Java SDK under Centos 7 more steps are required. As described in article, need to install Java SDK from RPM and then change settings of so called 'alternatives' to select proper JDK.
# rpm -ivh jdk-8u152-linux-x64.rpm
# java -version
OpenJDK Runtime Environment (rhel-2.6.12.0.el7_4-x86_64 u161-b00)
OpenJDK 64-Bit Server VM (build 24.161-b00, mixed mode)

# /usr/sbin/alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre/bin/java)
   2           /usr/java/jdk1.8.0_152/jre/bin/java

Enter to keep the current selection[+], or type selection number: 2
[root@vb_win7_32bit ~]# java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
  • Next to installation of Lucee itself. Download Lucee for Linux from official site.
wget http://cdn.lucee.org/lucee-5.2.4.037-pl0-linux-x64-installer.run

# chmod 755 lucee-5.2.4.037-pl0-linux-x64-installer.run
  • Follow instructions which are straightforward. Start Lucee service if it not started automatically. Then navigate to admin back-end to finish installation
http://devhost/lucee/admin/server.cfm
yum install epel-release

yum install dkms
# cd /media/
# mkdir cdrom
# mount -t iso9660 /dev/sr0 /media/cdrom
# cd /media/cdrom
# ./VBoxLinuxAdditions.run
sudo usermod -a -G vboxsf apache
EnableMMAP off
EnableSendfile off

That's it for setting up Apache and Lucee Virtualbox development environment. You may want to add ElasticSearch for logs, NodeJS or NoSQL database for modern web-development.