
[See the full index of articles for more information]
In this post, we’ll walk you through setting up RAD Server on Linux and deploying your project into production. It was written by Eli M.
Table of Contents
What is RAD Server?
RAD Server makes it fast and easy to build flexible back-end servers for your multi-tier Delphi or C++Builder application solution. Developers can choose from a number of built-in REST APIs or create their own custom APIs. RAD Server integrates with FireDAC giving you access to a wide variety of databases. The RAD Server Database is powered by InterBase for its backend and built-in API storage. If you have not already done so you will need to install InterBase on your RAD Studio machine to be able to run RAD Server locally.
There are six steps to deploy your RAD Server projects on Linux:
- Test Your Project With EMSDevServer
- Installing InterBase Which Powers RAD Server on Linux
- Run EMS Dev Server on Linux
- Deploy RAD Server
- Test RAD Server Installation
- RAD Server Installation Command Summary
Let’s look at each of these steps.
Test Your Project with EMSDevServer
Once you create a RAD Server project in RAD Studio, you will be able to compile the project and make your API available via the EMSDevServer. EMSDevServer is a standalone web server that comes with RAD Studio which can host your RAD Server APIs during development. EMSDevServer runs on both Windows and Linux. When you compile your RAD Server project for Win32 or Win64 it will automatically launch EMSDevServer with your endpoints available via localhost on port 8080 by default.
Installing InterBase Which Powers RAD Server on Linux
The RAD Server Database (powered by InterBase) will need to be installed and you can do this by installing InterBase on the Linux machine. Note: The RAD Server license does not allow you to use InterBase as a general-purpose database for storing application data, but only the specific data needed by RAD Server plus custom JSON-based data. Instructions for installing InterBase on Linux are available in the documentation under InterBase Quick Start: Part I – Installing InterBase for Linux and Installation, Registration, and Licensing Information. If you do not have unzip installed on your linux machine you can install it with this Linux command:
1 |
apt install unzip |
Once you have the InterBase ZIP file on your Linux machine, you can unpackage it with this Linux command:
1 |
unzip InterBase_2017_EN<span style="color: #000084; font-weight: bold;">.</span>zip |
Change to the new InterBase directory and run this Linux command:
1 |
sh <span style="color: #000084; font-weight: bold;">.</span><span style="color: #3f3fbf;">/install_linux_x86_64.sh</span> |
This will install InterBase for a 64bit environment from the command line. You can keep all of the default options during installation.
For a RAD Server production environment, you do not add a normal InterBase license. Instead you will need to install your RAD Server license into InterBase to be able to run RAD Server in production through Apache. You can add your RAD Server license to InterBase via the License Manager on the command line by running this Linux command:
1 |
<span style="color: #3f3fbf;">/opt/interbase/bin/LicenseManagerLauncher</span> -i Console |
You can set up InterBase to run at startup on the command line by running the following to create a script and then adding it to crontab:
1 2 3 |
<span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">'#!/bin/bash'</span> >> <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span>; <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">'/opt/interbase/bin/ibmgr -start -forever'</span> >> <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span>; chmod +x <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span> |
After you run the above commands at the Linux command line, you can run this Linux command:
1 |
crontab -e |
And then add the following line at the end of the file with your favorite editor (like nano).
1 |
@reboot <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span> |
Save and exit crontab.
Running EMS Dev Server on Linux
You can now run the RAD Server installation on Linux. If you do not have libcurl3 installed you will need to install it at the Linux command line by running:
1 |
apt install libcurl3 |
RAD Server contains an EMSServer directory with the two files ems_install.sh and LinuxEMSServer.tar. Copy these files to your Linux machine and execute the following command at the Linux command line to initiate and install RAD Server:
1 |
sh <span style="color: #000084; font-weight: bold;">.</span><span style="color: #3f3fbf;">/ems_install.sh</span> |
Once installed you will need to run the EMSDevServer to set up your emsserver.ib file and your emsserver.ini file via a wizard. You can do this by executing the following command at the Linux command line:
1 |
<span style="color: #3f3fbf;">/usr/lib/ems/EMSDevServerCommand</span> -start |
It will prompt you to run the wizard and you can say Yes to do that.
In the wizard setup you can keep all of the default options during installation. After the wizard setup is complete it will auto start EMS Server on port 8080. You can test it with this Linux command line:
1 |
wget localhost:8080<span style="color: #3f3fbf;">/version</span> |
After testing you can exit the EMSDevServer. You can find more complete instructions for finding and executing the EMS Server for Linux installation in the documentation under Configuring Your EMS Server or EMS Console Server on Linux.
At this point you should have InterBase running, you should have EMS Server installed, and you should be able to successfully visit the REST API endpoints of EMSDevServer via a web browser. You will only need EMSDevServer running during development if you will be using Apache in production.
Deploy RAD Server
The next step is to deploy your RAD Server and custom resource modules to Apache on Linux for production. You do not need EMSDevServer running during production if you have deployed EMS Server and your custom modules to Apache. Full detailed instructions for installing RAD Server into Apache are available in the documentation under Installing the RAD Server or the RAD Server Console on a Production Environment on Linux.
#1 Create a new file called ems.load in Apache’s mods-available directory. You can use a text editor such as nano from the Linux command line to create and edit the new file. Execute the nano /etc/apache2/mods-available/ems.load Linux command to edit the file. Add the following lines into the ems.load file:
1 2 |
LoadModule emsserver_module <span style="color: #3f3fbf;">/usr/lib/ems/libmod_emsserver.so</span> LoadModule emsconsole_module <span style="color: #3f3fbf;">/usr/lib/ems/libmod_emsconsole.so</span> |
#2 Create a second file called ems.conf in Apache’s mods-available directory. Execute the nano /etc/apache2/mods-available/ems.conf Linux command to edit the file. Add the following lines to the ems.conf file:
1 2 3 4 5 6 |
<span style="color: #808080; font-weight: bold;"><Location /ems-server></span> SetHandler libmod_emsserver-handler <span style="color: #808080; font-weight: bold;"></Location></span> <span style="color: #808080; font-weight: bold;"><Location /ems-console></span> SetHandler libmod_emsconsole-handler <span style="color: #808080; font-weight: bold;"></Location></span> |
#3 Enable RAD Server by running a2enmod ems at the Linux command line. You can disable RAD Server again by running a2dismod ems.
You can now copy your RAD Server custom resource modules (like bplProject1.so) to the /usr/lib/ems directory on Linux. You will need to edit your emsserver.ini file in the Server.Packages section and add your custom resource modules.
1 2 3 4 |
<span style="color: #808080; font-weight: bold;">[Server.Packages]</span> <span style="color: #808080;">;# This section is for extension packages.</span> <span style="color: #808080;">;# Extension packages are used to register custom resource endpoints</span> /usr/lib/ems/bplProject1.so=My Custom Project1 Resource Module |
Test the RAD Server Installation
Restart Apache by running service apache2 restart at the Linux command line. You should be able to test your new RAD Server installation on Apache by running wget localhost/ems-server/version at the Linux command line or by visiting that URL in your web browser.
RAD Server Installation Command Summary
Note: The below command summary is an approximate list of commands from this article. Your specific commands and directories may vary from what is listed below depending on the version of Linux you may be running and where you upload files. You will also still need to manually upload the ems_install.sh and LinuxEMSServer.tar files from your RAD Studio folder to the Linux machine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<span style="color: #808080;"># Install unzip</span> apt install unzip <span style="color: #808080;"># Download InterBase which powers the RAD Server Database</span> wget http:<span style="color: #3f3fbf;">/</span><span style="color: #3f3fbf;">/altd.embarcadero.com/download/interbase/2017/Update3/InterBase_2017_EN.zip</span> <span style="color: #808080;"># Unzip InterBase</span> unzip InterBase_2017_EN<span style="color: #000084; font-weight: bold;">.</span>zip <span style="color: #808080;"># Move to InterBase directory</span> <span style="color: #000084; font-weight: bold;">cd</span> InterBase <span style="color: #808080;"># Install InterBase 64</span> sh <span style="color: #000084; font-weight: bold;">.</span><span style="color: #3f3fbf;">/install_linux_x86_64.sh</span> <span style="color: #808080;"># Add the RAD Server License Key</span> <span style="color: #3f3fbf;">/opt/interbase/bin/LicenseManagerLauncher</span> -i Console <span style="color: #808080;"># Create Bash script to auto start InterBase</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">'#!/bin/bash'</span> >> <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span>; <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">'/opt/interbase/bin/ibmgr -start -forever'</span> >> <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span>; <span style="color: #808080;"># Make Bash script runnable</span> chmod +x <span style="color: #3f3fbf;">/opt/interbase/start_interbase.sh</span>; <span style="color: #808080;"># Add the script to cron to be run at startup</span> crontab -e <span style="color: #808080;"># and add this line inside: @reboot /opt/interbase/start_interbase.sh</span> <span style="color: #808080;"># Install libcurl13</span> apt install libcurl3 <span style="color: #808080;"># Download RAD Server install for Linux. Located in your RAD Studio directory.</span> <span style="color: #808080;"># wget ems_install.sh</span> <span style="color: #808080;"># wget LinuxEMSServer.tar</span> <span style="color: #808080;"># Run the RAD Server install script</span> sh <span style="color: #000084; font-weight: bold;">.</span><span style="color: #3f3fbf;">/ems_install.sh</span> <span style="color: #808080;"># Run EMSDevServerCommand to setup RAD Server database and emsserver.ini</span> <span style="color: #808080;"># Run setup wizard, test with wget, and then exit.</span> <span style="color: #3f3fbf;">/usr/lib/ems/EMSDevServerCommand</span> -start <span style="color: #808080;"># Test in a second console</span> wget localhost:8080<span style="color: #3f3fbf;">/version</span> <span style="color: #808080;"># Create ems.load and ems.conf for Apache</span> <span style="color: #000084; font-weight: bold;">if</span> [ <span style="color: #000084; font-weight: bold;" data-darkreader-inline-color="">!</span> -e <span style="color: #3f3fbf;" data-darkreader-inline-color="">/etc/apache2/mods-available/ems.load</span> ]; <span style="color: #000084; font-weight: bold;">then</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"LoadModule emsserver_module </span><span style="color: #3f3fbf;">/usr/lib/ems/libmod_emsserver.so</span><span style="color: #0000ff;">"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.load</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"LoadModule emsconsole_module </span><span style="color: #3f3fbf;">/usr/lib/ems/libmod_emsconsole.so</span><span style="color: #0000ff;">"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.load</span> <span style="color: #000084; font-weight: bold;">fi</span> <span style="color: #000084; font-weight: bold;">if</span> [ <span style="color: #000084; font-weight: bold;" data-darkreader-inline-color="">!</span> -e <span style="color: #3f3fbf;" data-darkreader-inline-color="">/etc/apache2/mods-available/ems.conf</span> ]; <span style="color: #000084; font-weight: bold;">then</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"<Location </span><span style="color: #3f3fbf;">/ems-server</span><span style="color: #0000ff;">>"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.conf</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"SetHandler libmod_emsserver-handler"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.conf</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"<</span><span style="color: #3f3fbf;">/Location</span><span style="color: #0000ff;">>"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.conf</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"<Location </span><span style="color: #3f3fbf;">/ems-console</span><span style="color: #0000ff;">>"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.conf</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"SetHandler libmod_emsconsole-handler"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.conf</span> <span style="color: #000084; font-weight: bold;">echo</span> <span style="color: #0000ff;">"<</span><span style="color: #3f3fbf;">/Location</span><span style="color: #0000ff;">>"</span> >> <span style="color: #3f3fbf;">/etc/apache2/mods-available/ems.conf</span> <span style="color: #000084; font-weight: bold;">fi</span> <span style="color: #808080;"># Enable the new Apache module</span> a2enmod ems <span style="color: #808080;"># Restart Apache</span> service apache2 restart <span style="color: #808080;"># Test RAD Server</span> wget <span style="color: #3f3fbf;">localhost/ems-server/version</span> |
Summary
With that your RAD Server is setup and your module is deployed. The following links have more information to help you along the path with your RAD Server journey.
- The Complete Guide to RAD Server eBook by David I. (only available to RAD Server Enterprise and Architect customers)
- Mobilizing your Business with Enterprise Mobility Services Middleware by Cary Jensen (webinar, whitepaper, and code)
- New RAD Server (EMS) Articles, Resources, and eBook
- Installing RAD Server for production on Linux With Apache

Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition