The absolutely quickest way to get started with Linux deployment from Delphi is to use the Windows Subsystem for Linux (WSL). As of Windows 10 Version 2004 (Build 19041) WSL2 includes a full Linux kernel, so debugging and everything works as expected.
- Install WSL2 (You can verify your build number via the System Information applet, but Build 19041 has been available for a while now.)
- Control Panel
- Turn Windows features on or off
- Windows Subsystem for Linux
- Install Ubuntu via the Microsoft Store – Ubuntu without version # is the current LTS version and will update in the future. There are other distributions (Kali, Pegwin, Alpine WSL, etc.), but they are all a little different.
- Launch Ubuntu – Via the Start Menu or from a PowerShell/Terminal/CLI window with the
Ubuntucommands. If you have more than one Linux installed then WSL launches the default one. The first time you launch it be aware it will take a few minutes, and then prompt you for new Linux credentials.
- Run SetupUbuntu4Delphi21.sh – I made a script on gist that does all the setup for Ubuntu to get it ready to target from Delphi. You can use
wgetto download it or you can type the commands manually. It creates a script file called pa21.sh in your home folder to quickly launch PAServer. You can modify it to pass default configuration settings.
echo Updating the local package directory
sudo apt update
echo Upgrade any outdated pacakges
sudo apt full-upgrade -y
echo Intall new packages necessary for Delphi
sudo apt install joe wget p7zip-full curl openssh-server build-essential zlib1g-dev libcurl4-gnutls-dev libncurses5 xorg libgl1-mesa-dev libosmesa-dev libgtk-3-bin -y
echo Clean-up unused packages
sudo apt autoremove -y
echo Downloading LinuxPAServer for Sydney 10.4 (21.0) Update 1
echo Setting up directories to extract PA Server into
tar xvf LinuxPAServer21.0.tar.gz -C PAServer/21.0 --strip-components=1
echo \#\!\/bin\/bash >pa21.sh
echo ~/PAServer/21.0/paserver >>pa21.sh
chmod +x pa21.sh
echo To launch PAServer type \~/pa21.sh
- Install FMXLinux from GetIt
- Run the
broadwaydserver – You should already have
paserverrunning (the script above launched it), so you will probably want a new Ubuntu terminal window where you can launch
broadwayd. I like using the new Windows Terminal since it makes it easy to open multiple tabs, and WSL integrates with it nicely.
- Import Linux SDK in Delphi IDE – Tools > Options > Deployment > SDK Manager – The IP address for the PAServer instance is localhost /
127.0.0.1, so keep in mind you are sharing ports between the WSL instance and your host Windows 10 OS.
- Now is just a matter of running most any FireMonky project and connecting to
localhost:8080from your browser.
One thing to keep in mind is there is one instance of the app running on the server for each client, and each has its own port number. There are ways to manage this on the server with a little effort, but that is a blog post for another day.