[See the full index of articles for more information]
This guide walks you through setting up RAD Server on Linux and deploying your project into production. It was written by Eli M.
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 your 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:
apt install unzip
Once you have the InterBase ZIP file on your Linux machine, you can unpackage it with this Linux command:
Change to the new InterBase directory and run this Linux command:
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:
/opt/interbase/bin/LicenseManagerLauncher -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:
echo '#!/bin/bash' >> /opt/interbase/start_interbase.sh</span>; echo '/opt/interbase/bin/ibmgr -start -forever' >> /opt/interbase/start_interbase.sh</span>; chmod +x /opt/interbase/start_interbase.sh
After you run the above commands at the Linux command line, you can run this Linux command:
And then add the following line at the end of the file with your favorite editor (like nano).
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:
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:
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:
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:
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:
LoadModule emsserver_module /usr/lib/ems/libmod_emsserver.so LoadModule emsconsole_module /usr/lib/ems/libmod_emsconsole.so
#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:
<Location /ems-server> SetHandler libmod_emsserver-handler </Location> <Location /ems-console> SetHandler libmod_emsconsole-handler </Location>
#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.
[Server.Packages] /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.
# Install unzip apt install unzip # Download InterBase which powers the RAD Server Database wget http://altd.embarcadero.com/download/interbase/2017/Update3/InterBase_2017_EN.zip # Unzip InterBase unzip InterBase_2017_EN.zip # Move to InterBase directory cd InterBase # Install InterBase 64 sh ./install_linux_x86_64.sh # Add the RAD Server License Key /opt/interbase/bin/LicenseManagerLauncher -i Console # Create Bash script to auto start InterBase echo '#!/bin/bash' >> /opt/interbase/start_interbase.sh</span>; echo '/opt/interbase/bin/ibmgr -start -forever' >> /opt/interbase/start_interbase.sh</span>; # Make Bash script runnable chmod +x /opt/interbase/start_interbase.sh</span>; # Add the script to cron to be run at startup crontab -e # and add this line inside: @reboot /opt/interbase/start_interbase.sh # Install libcurl13 apt install libcurl3 # Download RAD Server install for Linux. Located in your RAD Studio directory. # wget ems_install.sh # wget LinuxEMSServer.tar # Run the RAD Server install script sh ./ems_install.sh # Run EMSDevServerCommand to setup RAD Server database and emsserver.ini # Run setup wizard, test with wget, and then exit. /usr/lib/ems/EMSDevServerCommand -start # Test in a second console wget localhost:8080/version # Create ems.load and ems.conf for Apache if [ ! -e /etc/apache2/mods-available/ems.load</span> ]; then echo "LoadModule emsserver_module /usr/lib/ems/libmod_emsserver.so" >> /etc/apache2/mods-available/ems.load echo "LoadModule emsconsole_module /usr/lib/ems/libmod_emsconsole.so" >> /etc/apache2/mods-available/ems.load fi if [ ! -e /etc/apache2/mods-available/ems.conf</span> ]; then echo "<Location /ems-server>" >> /etc/apache2/mods-available/ems.conf echo "SetHandler libmod_emsserver-handler" >> /etc/apache2/mods-available/ems.conf echo "</Location>" >> /etc/apache2/mods-available/ems.conf echo "<Location /ems-console>" >> /etc/apache2/mods-available/ems.conf echo "SetHandler libmod_emsconsole-handler" >> /etc/apache2/mods-available/ems.conf echo "</Location>" >> /etc/apache2/mods-available/ems.conf fi # Enable the new Apache module a2enmod ems # Restart Apache service apache2 restart # Test RAD Server wget localhost/ems-server/version
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