UserGuide

Deploy Web App to Linux

From Xojo Documentation

Introduction

Web apps are often much simpler for your users and customers to use than desktop apps. They don't have to worry about installing any software or dealing with updates because now you do. Instead of your customers deploying your software on their computers, you have to deploy the software on your web servers.

In general, these are the steps to deploy a web app to a Linux server:

  1. Build your web app for Linux.
  2. Connect to your web server using an SFTP client of your choice (using Binary mode).
  3. Upload your web app (including the Libs and Resources folders)
  4. Verify that the execute flag is still set for the files that you just uploaded. Some FTP clients have been known to change this flag during upload.

But the specifics can be trickier.

You can deploy your web apps to Virtual Private Servers (VPS) with proper configuration. Shared Hosting typically does not work due to general lack of configurability. For the simplest hosting and deployment experience, you should consider using Xojo Cloud.

Additional information here:

  • Web App Deployment Overview
  • Web App Deployment Details

Standalone Web App

If you are uploading a standalone web app then you should follow these steps:

  1. Build your web app for Linux with the Standalone build setting selected.
  2. Connect to your web server using the FTP client of your choice.
  3. Navigate to the folder where you want your web app.
  4. Upload your web app (including the Libs and Resources folders) using Binary mode.
  5. Verify execute flag.

Now you need to run the standalone web app on the server. You'll need to connect to the server in order to do this, using ssh (Secure Shell). Secure Shell (and the ssh command) are available from the terminal or command line or Windows, macOS and Linux.

  1. Connect to the server using ssh (secure shell) with this command: ssh login@mywebsite.co
  2. Enter the password when prompted.
  3. Navigate to the folder where you uploaded your web app.
  4. Start the app using this command: ./TestApp

You can now access your web app in your web browser using the domain name and port. If "TestApp" was compiled to use port 8080, you can access it using a URL like this:

   http://www.mywebsite.com:8080

Note that if you exit from ssh your web app will terminate unless you daemonize it. Use this code in the App.Open event to daemonize a standalone web app:

Call Daemonize

On macOS, the use of Daemonize is discouraged by Apple. You should use launchd instead.

fa-info-circle-32.png
Xojo does not provide support for configuring your web server for use with Xojo web apps. If you require easy, one-click deployment of your Xojo web apps consider using Xojo Cloud.

Load Balancing

Using load balancing with standalone web apps can be a way to greatly increase concurrent users and improve performance. This blog post describes how HAProxy can be used with Xojo web apps:

CGI Web App

If you are uploading a CGI web app then you should follow these steps:

  1. Compile your web app for Linux with the CGI build setting selected.
  2. Connect to your web server using FTP.
  3. Navigate to the folder where your web server expects to find CGI app. This is often called cgi-bin.
  4. Upload your web app (including the Libs folder, Resources folder, config.cfg and cgi file). Use Binary mode.
  5. Verify execute flag.

If your web server is already configured properly to run CGI apps using Apache, then you will only need to type the URL in your browser. For example, for a web app called "TestApp", you would use a URL like this:

   http://www.mywebsite.com/cgi-bin/testapp.cgi


fa-info-circle-32.png
Xojo does not provide support for configuring your web server for use with Xojo web apps. If you require easy, one-click deployment of your Xojo web apps consider using Xojo Cloud.

Troubleshooting

Things don't always go this smoothly, however. This section has some tips for you as you troubleshoot.

32-bit Libraries

By default, 64-bit version of Linux do not include the 32-bit libraries that are needed by 32-bit Xojo web apps. Please refer to the System Requirements for details on how to apply the 32-bit libraries to your Linux distribution. Also make sure that the libicu library is available. You can avoid this step by building your web app as a 64-bit app.

Dependencies

Not all Linux installations have the necessary dependencies for Xojo apps pre-installed. Refer to the System Requirements for details. To determine which libraries are used by Xojo, you can use the ldd command:

   ldd Xojo

Web Logs

If you get an "Internal Server Error" or any error, you need to check the web server log for specifics. A common source of problems is incorrect permissions.

Permissions

Your web app needs to have the correct permissions enabled so that the web server can run the web app. This is done using the chown and chmod commands. The necessary permissions vary by the Linux distribution and Apache installation. Permissions of "755" are often a good starting point.

Unable to Launch App

This error indicates that the CGI (Perl script) has executed properly, but was unable to launch your web app. More information will follow this error, which is usually a “Permission denied” message. Some shared hosting users receive a “Connection refused” message. This message usually means the hosting provider has a security policy that prevents execution of your app. Check with your hosting provider if you receive this message.

Executable Settings

When uploading your web app to the server, ensure the app and its libs folder are uploaded in binary mode, everything else in ASCII mode. Many FTP clients get this correct automatically, but some do not.

If you get an error that says "Application launched, but unable to connect on port #", the CGI was able to launch your app, but was unable to connect to it using the port specified. Your host’s firewall may be blocking this port. You will need to deploy using a static port, and ask your host to open a port for you to use.

Unable to Locate a Library in Libs Folder

First, ensure you have uploaded all the contents of the Libs folder in Binary mode.

Check the Options FollowSymLinks in your Apache configuration.

Internal Server Error

This can mean any number of things. Check your web server logs. Some things to verify:

  • Ensure Apache is configured to allow CGI apps
  • Ensure Perl is installed and properly configured

See Also

UserGuide:Web App Deployment Overview, UserGuide:Web App Deployment Details topics