Disclosure: I searched a lot, and I don\'t think my question (for my configuration) is answered here. For example run python script as cgi apache server doesn\'t answer it.
In my case, I made a mistake with my ScriptAlias
directive. I uncommented the original one, but forgot to configure a new one.
As soon as I correctly changed and saved my sites-available/default
config file from this:
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
.. to this:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
.. and reloaded apache2, it just worked: it stopped displaying my scripts as text, and started running them as a script. Also, it no longer displayed /var/www/cgi-bin
as a directory in the browser, but now correctly displays the error:
Forbidden
You don't have permission to access /cgi-bin/ on this server.