Simple web/cgi query

In the old way, we had:

/…ibays/websitename/files
/…ibays/websitename/html
/…ibays/websitename/cgi-bin

Now we have

/…vhost/9278345yo198735089/

So… where should I be stashing my CGI scripts, so that they will be executed and not downloaded?

Thanks all!

Can you explain more detailed what you try to achieve? Where should the scripts run, at the client?
What the clients are, Linux, Windows, Mac? Which Browser do you use?

iirc CGI is Common Gateway Interface, the scripts run serverside and output html that’s returned the the client. It’s a bit old schooI I guess. The scripts can be anything, perl,python, whatever, so long as they output something the client can understand.

So the client isn’t relevant for this one really, the server takes a POST and sends it as an email then returns a nice HTML to the client saying thanks for your message.

If you just drop the script in the root directory of the web server, the server returns it to the client as text and it’s ungood.

in Apache, typically one adds an entry in the conf like “Location /cgi-bin” with “Directory /var/www/cgi-bin/” and "option ExecCGI’, or something like this, then the web server doesn’t return the file upon a GET request, instead it executes the file and returns the output.

I can probably just mess with the configs and make it work, but what’s the proper nethserver way to run CGI scripts?

@freakwent

Hi

I do have CGI-BIN running on NethServer - one of the things running is the NUT-CGI script:

This is the httpd.conf file (In /etc/httpd/conf/httpd.conf):

It seems no e-smith templates are needed for this (I did this 5 years ago…).
If you need CGI-BIN for a vhost, you’ll need to add a template…

I think all I needed to do was set permissions on the folder/file…

My 2 cents
Andy

Hrm. Can’t install perl-CGI using yum:

nethserver_packages = read_package_list()
File “/usr/lib/yum-plugins/nethserver_events.py”, line 88, in read_package_list
packages.remove(’$root’)
ValueError: list.remove(x): x not in list

yum clean all fixed that though.

It works now, I added a new config file in /etc/httpd/conf.d/ with:

<Directory “/var/lib/nethserver/vhost/3ee2d58d699827e/cgi-bin”>
AllowOverride None
Options None
Order allow,deny
Allow from all

and added
ScriptAlias /cgi-bin/ “/var/lib/nethserver/vhost/3ee2d58d699827e/cgi-bin/”
to conf.d/virtualhosts.conf.

Now I’ll need to either add this back in myself every time I make a vhosts change, or learn how to make a template and DB change that lets me enable CGI for a specific vhost. I chose option one.

2 Likes

A template is not a bad solution. Have a look here:
https://docs.nethserver.org/projects/nethserver-devel/en/latest/templates.html
If you have more question about it don’t hesitate to ask.

1 Like