GOLF(2gg)
π GOLF(2gg) β CGI π
okay so bestie, welcome to the Development section of the Golf manual, and this page is literally all about CGI β Golf documentation for the running-application vibe. grab a strawberry π and let's get into it.
β¨ NAME β¨
CGI β Golf documentation (running-application). that's the whole name, no notes, slay. π
πΈ DESCRIPTION πΈ
So here's the tea: you can run a Golf application as a CGI (Common Gateway Interface) program, if your web server supports CGI. cute, right?
ngl bestie, this is not recommended in general, because CGI programs do not exhibit great performance. like, they're giving "slow", no cap. π
But sometimes you just gotta. For example:
- when performance is not of critical importance, or
- when other methods of execution are not feasible.
Both valid. We've all been there. π«Ά
To run your application with CGI, use the command-line program. And here's the important part β since Golf applications require running in the security context of the user who owns the application, you must use "suexec" (or a similar feature) of your web server. no skipping this one. β
π¦ the setup script (iconic, honestly) π¦
The following script sets up an application named "func_test" (any kind of application will do, we're not picky) to run as CGI β after it's been compiled with gg β on an Apache web server running on Ubuntu 18 and up. For other web servers/distros, consult their documentation on how to setup CGI for a program. iykyk.
#prep repos
sudo apt update
#enable CGI on apache
sudo a2enmod cgid
sudo service apache2 restart
#Install suexec-custom for Apache
sudo apt-get -y install apache2-suexec-custom
sudo a2enmod suexec
sudo service apache2 restart
#setup a "gg" directory under cgi-bin where your application can run
sudo mkdir -p /usr/lib/cgi-bin/gg
sudo chown $(whoami):$(whoami) /usr/lib/cgi-bin/gg
sudo sed -i '1c\/usr/lib/cgi-bin/gg' /etc/apache2/suexec/www-data
#copy your program to "gg" directory
sudo mv $GG_ROOT/var/lib/gg/bld/func-test/func-test /usr/lib/cgi-bin/gg
sudo chown $(whoami):$(whoami) /usr/lib/cgi-bin/gg/func-test
sudo chmod 700 /usr/lib/cgi-bin/gg/func-test
#add user/group of Gliim application user to suexec
sudo sed -i "/SuexecUserGroup/d" /etc/apache2/sites-enabled/000-default.conf
sudo sed -i "s/<\/VirtualHost>/SuexecUserGroup $(whoami) $(whoami)\n<\/VirtualHost>/g" /etc/apache2/sites-enabled/000-default.conf
sudo service apache2 restart
#the application is at http://127.0.0.1/cgi-bin/gg/func-test?...
#substitute 127.0.0.1 for your web address
and boom, your app is live at that URL. main character energy fr fr. π
π₯ SEE ALSO π₯
- Running application
application-setup- CGI
command-lineservice- See all documentation
go read those too, bestie, they're all part of the lore. β¨
okay that's the whole page!! this one came from the Development chapter, version $VERSION and it's dated $DATE. stay hydrated, back up your configs, and don't forget the suexec step πππ§
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms