Would you like to learn how to install Apache and enable the use of GO CGIs on a computer running Ubuntu Linux? In this tutorial, we are going to show you how to enable the CGI feature and enable GO scripts to run on the Apache server.

• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Apache 2.4.41
• GO 1.14.16

Copyright © 2018-2021 by Techexpert.tips.
All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of the publisher.

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Ubuntu - GO CGI on Apache

Install the Apache server and enable the module named CGID.

Copy to Clipboard

Restart the Apache service.

Copy to Clipboard

Download and install the GO package.

Copy to Clipboard

The GOLANG software was installed under the /usr/local folder.

In order to work properly, the GO software expect the system to have a set of environment variables.

Let's create a file to automate the required environment variables configuration.

Copy to Clipboard

Here is the file content.

Copy to Clipboard

Reboot your computer.

Copy to Clipboard

Verify if the required environment variables were created automatically.

Copy to Clipboard

Here is the correct output:

Copy to Clipboard

As an example, let's create a GO script.

Copy to Clipboard

Here is the file content.

Copy to Clipboard

Build the GO script and move it to the Apache CGI directory.

Copy to Clipboard

Access the Apache's CGI directory.

Change the file permission.

Copy to Clipboard

Open your browser and enter the IP address of your web server plus /cgi-bin/test.go.

In our example, the following URL was entered in the Browser:

• http://172.31.8.195/cgi-bin/test.go

The GO script should display the following message.

Apache CGI GO

Congratulations! You are now able to use the GO as CGI.