Using compiled CGI executables on web hosting

Hello! I haven't found much documentation on this topic: can you run precompiled CGI binaries (C with a dynamic MySQL dependency) on a shared web‑hosting plan (specifically Starter).

I compiled them with GCC on Linux x86_64. If anyone would like to take a look at my Makefile, let me know if that would help.

I tried putting them on the server (www/, www/cgi-bin/) but nothing works. A 500 error on every attempt. The HTTP and server logs haven't really helped.

Thanks in advance!

Hello @AdamE2,

Indeed, it would be useful to share as much information as possible so that the community can give you a tailored response. :slight_smile:

^FabL

Here it is:

CC = gcc
CFLAGS = -std=c99 -Os -Wall -Wextra
LDFLAGS = -lmysqlclient

index = src/index.c
create_thread = src/create_thread.c
create_reply = src/create_reply.c
thread = src/thread.c
db = src/db.c
cgic = vendor/cgic.c

all:
$(CC) $(CFLAGS) $(LDFLAGS) $(index) $(cgic) $(db) -o index.cgi
$(CC) $(CFLAGS) $(LDFLAGS) $(create_thread) $(cgic) $(db)
-o create_thread.cgi
$(CC) $(CFLAGS) $(LDFLAGS) $(create_reply) $(cgic) $(db)
-o create_reply.cgi
$(CC) $(CFLAGS) $(LDFLAGS) $(thread) $(db) $(cgic) -o thread.cgi

It's not very clean, but it runs on all my computers... I wouldn't be surprised if the problem is the missing mysqlclient library on the shared‑hosting servers. I also haven't been able to find a static version of it.

Hi,

It's not my specialty, but I'd be very surprised if you could run a binary like that.
You should get a VPS or a dedicated server for that.

Ah. Well, thanks! I’ll leave the thread open just in case!

Well, you need to use -no-pie to compile. I managed to get a dummy test running.

It doesn’t work with github.com/boutell/cgic...