How do I install Livecode Server with Apache 2.4 on a Synology with x86 CPU and DSM7

This lesson explains the needed steps to get Livecode Server running with Apache 2.4 on a Synology NAS with an x86 CPU and DSM 7

For this lesson we used  a fresh installed Synology device with DSM 7.1.

The steps were successfully tested on a Synology DS415+ and DS 1821+ with Livecode Server 9.6.9RC2 and Livecode Server Pro 9.6.9RC2.

 

1. What is needed

Synology:

  • Synology NAS with x86 CPU and DSM 7 installed

Make sure that you have the  Admin credentials (username and password) of your Synology available.

 

Software:

  • SSH Client for your Desktop computer

On macOS  an SSH Client is installed by default.

On Microsoft Windows 10/11 you have to manually install it using the following steps

  1. Go to Settings > Apps > Apps & features > Optional features and click on Add a feature.
  2. Locate “OpenSSH server” feature, expand it, and select Install.
  • Livecode Server

Download Livecode Server for Linux64 from within your Livecode Account. Keep the .zip file. Do not extract it.

 

2. DSM File Services Configuration

In this chapter we  setup SFTP and SSH services on the Synology NAS

2.1. Enable SSH

  1. Open Control Panel in DSM
  2. Go to File Services (1)
  3. Select Terminal pane (2)
  4. Check Enable SSH service (3)
  5. Change Port from 22 to 8228 (4) This is optional.
  6. Click on the blue Apply button

2.2. Enable SFTP (optional)

  1. Open Control Panel in DSM
  2. Go to File Services (1)
  3. Select FTP pane (2)
  4. Check Enable SFTP service (3)
  5. Change Port from 22 to 8228 (4) This is optional.
  6. Click on the blue Apply button

Enabling SFTP is optional. The author of this lesson prefers to upload Livecode Server scripts (*.lc) to his Synology NAS using SFTP. Therefore he has enabled SFTP in the file services. Enabling SFTP is not mandatory. In addition, this can also be done later, if needed.

3. Install Apache 2.4 & Web Station

In this chapter we install Apache 2.4 and, in case it is not already installed, Web Station using the Package Center

3.1. Apache 2.4

Login into your DSM account on your Synology and open the Package Center

Then click on Installed (1), enter apache in the search field (2) and click on Install (3)

 

3.2. Web Station ( in case it was not already installed)

Apache  also needs Web Station to be installed. If Web Station is not yet installed, you will see the following message, telling you that Web Station will also be installed.

Confirm that message by clicking on Yes

 

4. Install Livecode Server

In this chapter we upload and extract the Livecode Server zip file we've downloaded from Livecode.

4.1. Create cgi-bin folder

  1. Open File Station (1)
  2. Click on web (2)
  3. Click on Create (3)
  4. Click on Create Folder (4)
  5. In the upcoming dialog enter cgi-bin and click on OK.

4.2. Upload  Livecode Server to NAS

  1. Click on the little triangle to expand the folder tree of the folder web (1)
  2. Click on cgi-bin (2)
  3. Click on Upload (3)
  4. Click on any of the 2 options. (4). As we just upload a new file, we can choose any of that options
  5. In the upcoming dialog select the Livecode Server .zip file and confirm to upload it to the Synology NAS

4.3. Extract Livecode Server

  1. Right click on the Livecode Server zip file (1)
  2. Move mouse pointer onto Extract (2) - a menu opens
  3. Select Extract Here (3) from the menu

Livecode Server will be extracted

 

4.4. Delete Livecode Server .zip file (optional)

This is how the content of the folder cgi-bin should look like after extraction.

If you want, you can delete the zip file now. Right-click on the zip file (1) and click Delete (2) in the upcoming menu. Confirm the deletion by clicking on Delele in the pop up dialog.

5. Apache and Web Station Configuration

In this chapter we configure Web Station and Apache

5.1. Webstation Configuration - Apache as HTTP back-end server

  1. Double-click on Main Menu (1)
  2. In Main Menu click on Web Station
  3. In Web Station click on Web Service Portal (2)
  4. Double-click the default entry (3)
  5. Select Apache HTTP Server 2.4 as HTTP back-end server. (4)
  6. Click on Save button (5)

5.2. Apache Configuration

5.2.1. Connect to NAS using SSH

To change the Apache configuration we need to access the NAS by SSH. We need  admin credentials for this.

1. connect to the NAS using the following shell command (identical for macOS and Windows 10/11)

ssh  <admin>@<ip-address> -p <port>

replace <admin> with your NAS admin username

replace <ip-address> with the ip-adress of your NAS

replace <port> with the port you've set  when enabling SSH. Default port is 22. In our lesson we changed to 8228

Example

ssh [email protected] -p 8228

When asked, please enter your password for the NAS admin account.

 

 

5.2.2. Edit configuration file

Now we want to create a configuration file. In our example we use the file name lcserver.conf

After successful login enter the following shell command to switch to the folder where the custom configuration files are located:

cd /usr/local/etc/apache24/sites-enabled/

and then  to open the editor enter this shell command:

sudo vi lcserver.conf

You will be asked for the NAS admin password. After entering the correct password the editor opens.

 

Now in the empty editor window press just i

This switches the editor to Insert mode.

You will see now  -- INSERT -- in the left lower corner of the window.

Now enter the following text into the editor. You can also copy the below text to clipboard and can then paste it into the editor.

<Directory "/var/services/web/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
    AddHandler livecode-script .lc
    Action livecode-script /livecode-cgi/livecode-server
</Directory>
<Directory "/var/services/web/cgi-bin/">
    Options ExecCGI
    Require all granted
</Directory>
ScriptAlias /livecode-cgi/livecode-server "/var/services/web/cgi-bin/livecode-server"
Click to copy

This above text  will tell Apache how to handle files with the extension .lc. In our case we tell Apache that .lc files shall be executed with livecode-server which is located in the folder  /var/services/web/cgi-bin/

 

5.2.2.1. Save the file and quit the editor

After entering/copying the text, press ESC  then : and then x. You should see now   :x in the lower left corner of the editor window. This will tell the editor that we want to save the file and then to exit the editor.

Press the Return/Enter key to confirm our command :x

Now after the editor was closed execute the shell command

ls -al  

to see if the file  lcserver.conf does exist.

Actually, an error message should have come up if an error occurred while writing, but we check it anyway.

If the file doesn't exist, then please repeat the steps for creating the file

If the file exists, then run  the following shell command to set the correct permissions for the file

sudo chmod go+r lcserver.conf

 

5.2.3. Restart Apache

To make Apache take notice of our changes we have to restart Apache. There are several ways to restart Apacher. One would be to restart the complete NAS. But using a shell command we can restart Apache within seconds.

While still connected to the NAS with our SSH client, enter the following command

sudo systemctl restart pkg-apache24.service

 

Now we can test if Livecode Server is working.

 

6. Test Livecode Server installation

6.1. Create test script

Create a test script and save it in the web folder. You could create that file with your editor of your Desktop computer then upload it using File Station in DSM or you could connect with SFTP to the NAS and upload the file using an FTP Client.

Our test script looks like this

<?lc
put "Hello World!"
?>
Click to copy

6.2. Run test script in Browser

Now when we call the script in our browser,  we can see

If you see an error message instead of Hello World! then there might be a syntax error in your script.

If you just see the complete script or the browser downloaded the script  instead of showing Hello World! then something went wrong with the configuration. In this case please check if Webstation was correctly set to use Apache instead of NGINX and if the file lcserver.conf contains the correct text. Or maybe Apache was not restarted after creating lcserver.conf.

Please note that Apache needs to be restarted every time when the lcserver.conf file was modified. Otherwise Apache will still use the previous version of lcserver.conf.

 

 

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.