Run cgi from any directory Apache 2.4

How can I get our server to run cgi from any folder I want?

Apache version 2.4 prevents the use of CGI scripts in directories other than the cgi-bin directory. To use CGI scripts in other directories, you must enable the ability of individual .htaccess files to override the server settings.

How does one get around this?

@Richard Albrecht — There is probably a good reason for Apache to restrict use of CGI. My advice would be for you to comply and move all your CGIs into the cgi-bin folder.

Not really a good option. We have like 20 web apps. We are moving to a new server, our current server allows it?

@Greg O’Lone

You must have encountered this before?

I think we enable scripting for years now by htaccess file!?

Yes but you need to configure the server to allow the htaccess to over ride the default.

Subdirectories? Doesn’t that work? Seems like I remember that working, but I don’t use CGI.

Other ways besides .htaccess

Apache

I remember last time I configured Apache, the cgi-bin configuration was disabled, so no cgi app by default could be run. You need to activate the cgi-bin (that you can rename).

I think one option is configure apps as cgi-bin directory and to something like this:
yourdomain.com/apps/app1/
yourdomain.com/apps/app2/

Other option is having a subdomain:
apps.yourdomain.com/app1/
apps.yourdomain.com/app2/

I haven’t done this but I think you can configure several cgi-bin directories with different names:
yourdomain.com/app1/
yourdomain.com/app2/

I think is better to specifically configure each directory that you are going to use to run CGI than use htaccess with the option to activate the directory as a cgi capable one.

After reading again your question, I’m not sure if you want to know how to configure Apache so you can use htaccess to let cgi apps run in any directory, or if you want to configure your Apache that by default you can run cgi apps in any directory without the need of htaccess.

[quote=445767:@Richard Albrecht]@Greg O’Lone

You must have encountered this before?[/quote]
Send me a private note showing what your Apache virtual host config looks like and I’ll take a look.

@Greg O’Lone

It can’t find you. I tried it says: Hm, there doesn’t seem to be a member with that name.

This company American Eagle is driving me nuts trying to get cgi’s to run. They are a large company located just outside Chicago and they are doing our new website.

@Greg O’Lone I have the file.

Send me an email rich@aspe.org

Here’s what happens when running the Linux executable:

Here is output

/home/asperichard/public_html/cgi-bin/xo/TestXojo

[root@cl-aspe-4vap01 TestXojo]# strace ./TestXojo
execve("./TestXojo", ["./TestXojo"], [/* 25 vars */]) = 0
brk(NULL) = 0x7e2000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f705e8e3000
readlink("/proc/self/exe", “/home/asperichard/public_html/cg”…, 4096) = 58
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/tls/x86_64/XojoConsoleFramework64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/tls/x86_64", 0x7ffc5a834f00) = -1 ENOENT (No such file or directory)
open("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/tls/XojoConsoleFramework64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/tls", 0x7ffc5a834f00) = -1 ENOENT (No such file or directory)
open("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/x86_64/XojoConsoleFramework64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/x86_64", 0x7ffc5a834f00) = -1 ENOENT (No such file or directory)
open("/home/asperichard/public_html/cgi-bin/xo/TestXojo/TestXojo Libs/XojoConsoleFramework64.so", O_RDONLY|O_CLOEXEC) = 3
read(3, “\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@V\33\0\0\0\0\0”…, 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=36566632, …}) = 0

It goes on…