Xojo Web Apps on a Raspberry Pi Webserver

I will receive a Raspberry Pi 4 with 4GB next week and would like to setup a Linux Webserver on it, for Xojo Web Apps.

Does anyone have a recommended Setup (Linux, Librarys, Apps, …) or even a Script i can run which would install the needed Components on Raspbian or anything alike?

BTW: Wouldn’t it be a nice Community Project? Maybe a GitHub Repo in which we maintain/offer a Script for Xojo web App Devs which would prepare a recommended Linux for Xojo Web Apps? :slight_smile:

I am not that experienced with Linux but will try to save my findings for later use in a Script and i will offer it then on GitHub. But because of my missing Linux Background, i can’t promise that i will really get to a point at which i can offer something.

It is just like setting up a webapp on a Ubuntu/Debian server. I had no issues at all, runs like a charm.
https://documentation.xojo.com/topics/application_deployment/web/deployment_overview.html

Thank you @Oliver Osswald , sounds promising.

I was affraid that i may get a bit in trouble because of the CGI Stuff. But i like challenges :slight_smile:

Don’t worry (much) about the CGI stuff, Web 2.0 will only create standalone IIRC.

I now have my Raspberry. Installed Raspian (headless). Installed apache2, php, mariadb and samba (for file sharing).

I placed a simple Hello World Xojo Web App into my /usr/lib/cgi-bin folder.
After trying to open the App within my local Network via http:///cgi-bin/test.cgi, is see the following in the apache error.log:

AH01215: /usr/lib/cgi-bin/test: 1: /usr/lib/cgi-bin/test: Syntax error: Unterminated quoted string: /usr/lib/cgi-bin/test.cgi AH01215: Use of uninitialized value $length in subtraction (-) at /usr/lib/cgi-bin/test.cgi line 131.: /usr/lib/cgi-bin/test.cgi AH01215: Use of uninitialized value $length in numeric eq (==) at /usr/lib/cgi-bin/test.cgi line 130.: /usr/lib/cgi-bin/test.cgi End of script output before headers: test.cgi

PHP scripts in /var/www/html working as expected.

Could not find a solution in the internet :confused:

Why are you not using standalone webapp?

  • you don‘t need Apache
  • it is faster, faster response
  • easier to install
  • not deprecated (as Xojo cgi)

[quote=480044:@Oliver Osswald]Why are you not using standalone webapp?

  • you don‘t need Apache
  • it is faster, faster response
  • easier to install
  • not deprecated (as Xojo cgi)[/quote]

Because i get:

AH01215: (8)Exec format error: exec of '/usr/lib/cgi-bin/test' failed: /usr/lib/cgi-bin/test End of script output before headers: test

I can’t find a manual describing how to setup a Pi for Xojo Web Apps.

https://documentation.xojo.com/getting_started/creating_more_apps/raspberry_pi/introduction_to_xojo_pi.html

Install raspian desktop
Install libunwind8
Compile your Xojo web app for Linux/arm on your Mac or PC
Drag the app to the Pi
Double click the app on the pi

[quote=480056:@Andy Broughton]Install raspian desktop
Install libunwind8
Compile your Xojo web app for Linux/arm on your Mac or PC
Drag the app to the Pi
Double click the app on the pi[/quote]

That works just fine with Desktop Apps, but i would like to create Web Apps and access them within my local Network and i would like to use a mySQL Server on the Pi for Data Storing and Sharing. :slight_smile:

Get SSH access to your raspi first.

Then I usually install webmin in order to have a webinterface for administration of a linux server.

EDIT:
Here a straightforward webmin install from commandline
http://ubuntuhandbook.org/index.php/2019/11/install-latest-webmin-ubuntu-18-04/

On Raspi you may need to install all the required packages of Webmin.

sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
See here: https://pimylifeup.com/raspberry-pi-webmin/

Once I have access, I create a folder in /opt where I copy my Xojo webapp
Then you can start your webapp by typing something like this in your terminal:

sudo /opt/webapps/MyWebApp

One way to keep your webapp alive or have it autostart after a reboot, is by adding a small script and a cron job.
How I do this is described in this thread:
https://forum.xojo.com/57766-webapp-at-ubuntu-18-04-lts/p1#p469286

My personal favorite for sftp file transfer is Transmit
https://www.panic.com/transmit/

It is the same as for any Debain Linux Server, like Ubuntu for instance

Thank you @Oliver Osswald and @Andy Broughton !

My assumption was, i would have to run a Webserver and the “start” the Web App from the Browser using just a URL.

I have my App finally up and running :slight_smile:

For future reference, here is what i did:

  1. I “installed” the latest Raspbian (with no Desktop/headless) on my SD Card and placed an empty text file called “ssh” in the main folder of the boot Partition.
  2. I connected via ssh to my Raspberry now running Raspbian and updated/upgraded it and set it up using raspi-config
  3. I installed libunwind8 (sudo apt-get install libunwind8)
  4. I gave the pi User ownership of the /opt/ Folder (sudo chown pi /opt/)
  5. Using a SFTP Connection, i created a Folder in /opt/ and placed my App within it
  6. Then, i made my App executable (chmod 0755 /opt/test/test)
  7. I started my app (/opt/test/test)

Now i can access my App via any Browser in my local Network using the IP Adress/Hostname + the Port i have choosen in Xojo Shared Build Settings (http://Schneppi-Webserver:8080)

Just for anyone who comes later to this thread, you may also consider of adding such code to your App.Open event handler:

[code]Me.AutoQuit=False

// Allow your app to show up in any iframe
Self.Security.FrameEmbedding = WebAppSecurityOptions.FrameOptions.Allow

#If Not DebugBuild Then // Do not try to daemonize a debug build
Call Me.Daemonize
#endif[/code]

[quote=480068:@Oliver Osswald]Just for anyone who comes later to this thread, you may also consider of adding such code to your App.Open event handler:

[code]Me.AutoQuit=False

// Allow your app to show up in any iframe
Self.Security.FrameEmbedding = WebAppSecurityOptions.FrameOptions.Allow

#If Not DebugBuild Then // Do not try to daemonize a debug build
Call Me.Daemonize
#endif[/code][/quote]

If i do this, i should add an Exit (Quit) Option to my App. Correct? Or how would i force quit it from the shell?

Yes, you add a quit button, link or whatever.

Or you kill your app from the command line:

Get the id of your process (like 123):

pidof MyWebApp

Kill the process:

kill 123

EDITED:
If you want to autoquit your webapp as soon as you have deleted the program files, then you add a property of type timer to the App object plus a method ‘QuitTimer_Action’:

[code]Private Sub QuitTimer_Action(sender As Timer)
#Pragma Unused sender

Dim f As FolderItem
f = GetFolderItem("")
Dim n As String = Lowercase(App.ExecutableFile.Name)
f = GetFolderItem(f.NativePath + n)
If (f.Exists = False) Then
#IF Not DebugBuild
App.Quit
#ENDIF
End If
End Sub
[/code]

And in Open Event Handler you add code like this:

// Start a timer which runs a AutoQuit method QuitTimer = New Timer AddHandler QuitTimer.Action, AddressOf QuitTimer_Action QuitTimer.Period = 5000 QuitTimer.Mode = Timer.ModeMultiple

For anyone who would like to use a mySQL Database on the Pi within your Apps.

Install MariaDB with sudo apt-get install mariadb-server

If you would like to Manage your Datases with an App like Valentina Studio from your Desktop:

  1. Access the mySQL Shell using mysql -u root
  2. Enter GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YOUR-DB-ROOT-PASSWORD' WITH GRANT OPTION;
  3. Do a FLUSH PRIVILEGES;

Instead of ‘root’@’%’ you can also use ‘root’@‘192.168.178.10’ to restrict the access to a specific address or with the % placeholder to address ranges (f.e. ‘root’@‘192.168.178.%’

Exit the mySQL Shell with exit and restart the MariaDB Server with sudo systemctl stop mariadb and then sudo systemctl rt mariadb

[quote=480067:@Sascha S]Thank you @Oliver Osswald and @Andy Broughton !

My assumption was, i would have to run a Webserver and the “start” the Web App from the Browser using just a URL.

I have my App finally up and running :slight_smile:

For future reference, here is what i did:

  1. I “installed” the latest Raspbian (with no Desktop/headless) on my SD Card and placed an empty text file called “ssh” in the main folder of the boot Partition.
  2. I connected via ssh to my Raspberry now running Raspbian and updated/upgraded it and set it up using raspi-config
  3. I installed libunwind8 (sudo apt-get install libunwind8)
  4. I gave the pi User ownership of the /opt/ Folder (sudo chown pi /opt/)
  5. Using a SFTP Connection, i created a Folder in /opt/ and placed my App within it
  6. Then, i made my App executable (chmod 0755 /opt/test/test)
  7. I started my app (/opt/test/test)

Now i can access my App via any Browser in my local Network using the IP Adress/Hostname + the Port i have choosen in Xojo Shared Build Settings (http://Schneppi-Webserver:8080)[/quote]
Just like I said! (with a couple of extra steps) Glad you got it working.