Writing CGI scripts in 2026

I’ve been playing with the “old” CGI tech, I remember seeing the “cgi-bin” directories in the document roots of sites hosted on DirectAdmin/Cpanel servers, and I figured I wanted to play with it. It’s quite nice how raw and simple the CGI interface is.

Anyone else played with making new CGI scripts here?

4 Likes

I’ve been tempted, but there are other things I want to do with my website first.

I’ve been meaning to. Not just for the web: text-based browsers can run CGI scripts directly, so you can use the same tech to make local apps. Something to try later I guess.

Yes! Earlier this year idk what got into me but I programmed a lot in Perl and spent some time configuring a VPS to run cgi scripts. It’s tons of fun seeing how these technologies influence modern ones.

I found my happy medium with vanilla PHP though :-)

2 Likes

I think PHP technically still uses the CGI protocl, even with fcgi/fpm. At least CGI shows up in some environment variables.

The guestbook on both my sites are put together with a cgi program, as is the content served from the projects page on my second site (it serves plain text into an iframe).

I just wrote programs, compiled binaries, and loaded them into the cgi folder. Told the html button to fire off that program on click, and it works.

1 Like

I thought about trying to wrap some more modern apps in CGI to get them working on shared hosting. I wanted to “scale to zero” which is a bit difficult to do with Django or nodejs.

I did some research, and an approach I might try is using inetd in “wait” mode. uWSGI can shut itself down if it is idle and inetd can start it up again when it is needed.

I think uWSGI in inetd/wait mode would be quite slow and heavy though. Loading Django VS a single (probably small) CGI script is quite different.

I think when I played with alwaysdata.com they did shut down the uwsgi process after 300s of inactivity, but I also remembered bots making it essentially never shut down

A mix of static and dynamic parts would probably be needed to get decent performance and have any hope of spinning down.