LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   cgi scripts not working on the httpd server (https://www.linuxquestions.org/questions/linux-server-73/cgi-scripts-not-working-on-the-httpd-server-4175439087/)

Roboserg 11-28-2012 03:54 AM

cgi scripts not working on the httpd server
 
I have an ARM linux board with 2.6.34 Linux on it with Busybox v1.15.0

I start the httpd server with the following parameters:
httpd -p 80 -h /root/www. The html pages work.
Then there is /root/www/cgi-bin folder, where I put my cgi scipt. If I try to load the script with "192.168.X.X/cgi-bin/my-cgi-scipt I get "404 page not found".

I set permissions for the script and the cgi-bin to 777.
I also tried to make my own config file "httpd.conf" and put in into /etc/ with the following content:

Code:

H:/root/www
I:/root/www/index.html
A:*

But then if I start the server with "httpd" in the console I get "): No such file or directory".

So the question is - how do I enable cgi on httpd ?

Roboserg 11-29-2012 09:22 AM

Bump.
I cant believe noone uses httpd server and / or CGI. Need urgent help with this.

TenTenths 11-30-2012 10:05 AM

Urgent for you isn't necessarily urgent for us.

Have you tried following the example instructions which I found with a 10 second google search: http://wiki.openwrt.org/doc/howto/http.httpd

Roboserg 12-04-2012 05:48 AM

Quote:

Originally Posted by TenTenths (Post 4840243)
Urgent for you isn't necessarily urgent for us.

Have you tried following the example instructions which I found with a 10 second google search: http://wiki.openwrt.org/doc/howto/http.httpd

I found that link within 5 seconds google search before I posted the question on this forum and the article doesnt help in any way. But sticking to that article I have the following:

httpd works without a configuration file. Default is /etc/httpd.conf

I tried with and without a config. I already posted earlier what I had in the config. Checked.

httpd expects it's CGI script files to be in the subdirectory cgi-bin under main web directory set by options -h (default is /www, so /www/cgi-bin).

I also have the root of the webserve at /wwww and the cgi subdirectory at /www/cgi-bin. Checked.

The CGI script files must also have permission to be executed (min mode 700).

I set the permission for the whole www folder to 777. Checked.

So then in the folder /www/cgi-bin I have a file called testcgi with the following content:

Code:

#!/bin/sh

# disable filename globbing
set -f
echo Content-type: text/plain
echo
echo CGI/1.0 test script report:
echo
echo argc is $#. argv is "$*".
echo
echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME

Then I try to access the webserver from my host machine with: http://192.168.10.32 and I get the index.html webpage. So far so good. Now I try to access the cgi script with http://192.168.10.32/cgi-bin/testcgi without having any etc/httpd.conf and I get in the browser:

Code:

404 Not Found
The requested URL was not found

What happens if I do have the config I already described in my previous post.

The article you gave doesnt say how to activate cgi which implies the cgi is working by default by running the httpd server.

You signature says you are a RHCT and have 15 y of experience with linux. I am sure this problem should be trivial for you.

TenTenths 12-04-2012 05:53 AM

Quote:

Originally Posted by Roboserg (Post 4842391)
You signature says you are a RHCT and have 15 y of experience with linux. I am sure this problem should be trivial for you.

Unfortunately the bulk of my experience is with high-end servers and apache, not the embeded http server for Busybox.

jsaravana87 12-04-2012 09:32 AM

Check your cgi module installed

#httpd -M

Checked whether you had loaded cgi module in your httpd.conf file


LoadModule cgi_module modules/mod_cgi.so


Look after the article

http://httpd.apache.org/docs/2.2/howto/cgi.html

TenTenths 12-04-2012 10:12 AM

Quote:

Originally Posted by arun5002 (Post 4842598)
Check your cgi module installed

#httpd -M

Checked whether you had loaded cgi module in your httpd.conf file


LoadModule cgi_module modules/mod_cgi.so


Look after the article

http://httpd.apache.org/docs/2.2/howto/cgi.html

And if it was Apache and not the Busybox in-built http server then that would be relevant! :P

Roboserg 12-05-2012 02:28 AM

So this is all weird. If I use the following https.conf:
Code:

H:/root/www
and start the server with httpd -v the server starts.

If I use
Code:

H:/root/www
/cgi-bin:foo:bar

OR

Code:

H:/root/www
/root/www/cgi-bin:foo:bar

I get "): No such file or directory"

For the config I looked here:
http://wiki.chumby.com/index.php/Usi...ox_HTTP_server. The "/root/www/cgi-bin:foo:bar" should be a valid config command.

Roboserg 12-05-2012 03:06 AM

Another weird thing is that I cant run my cgi script from the console. If I navigate to /root/www/cgi-bin/ and list all files I see the "testcgi" file. If I try to execute this file with "./testcgi" I get "file not found" in the console. :confused:
Whats going on oO

TenTenths 12-06-2012 02:14 AM

Ok, I'd assumed you'd checked that your script would run in the console. First thing to check in this case is that it does have permissions that allow execution, 755 or 777 and that the #! line is the very first line of the file, and that there is indeed an executable shell by running /bin/sh

Roboserg 12-06-2012 04:10 AM

Quote:

Originally Posted by TenTenths (Post 4843637)
Ok, I'd assumed you'd checked that your script would run in the console. First thing to check in this case is that it does have permissions that allow execution, 755 or 777 and that the #! line is the very first line of the file, and that there is indeed an executable shell by running /bin/sh

The cgi-bin/ directory has chmod 777 and the CGI script file look like that:

Code:

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "Sample CGI Output"
echo ""
echo ""
echo ""
echo ""

If I type "sh testcgi" I get it working in the console. If I type "./testcgi" I get "not found" :Pengy:

TenTenths 12-06-2012 04:16 AM

Quote:

Originally Posted by Roboserg (Post 4843671)
The cgi-bin/ directory has chmod 777 and the CGI script file look like that:

Code:

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "Sample CGI Output"
echo ""
echo ""
echo ""
echo ""

If I type "sh testcgi" I get it working in the console. If I type "./testcgi" I get "not found" :Pengy:

Ok, try typing "which sh" and see if you get a result like /bin/sh or /sbin/sh or similar. Whatever you get back use that at the #! in the first line of the script.

Roboserg 12-06-2012 05:47 AM

"which sh" gives me "/bin/sh" so it was right. And I dont understand why I cant run the script via "./testcgi" getting "not found".

If I remove #!/bin/sh line I get execute the script with "./testcgi" but the web servers still doesnt find the file saying "404 page not found".

TenTenths 12-06-2012 06:11 AM

I'm stumped then, suggest you raise this on a Busybox forum?

Roboserg 12-06-2012 06:20 AM

Quote:

Originally Posted by TenTenths (Post 4843716)
I'm stumped then, suggest you raise this on a Busybox forum?

It may sound stupid but I didnt found any busybox official forums ... :(


All times are GMT -5. The time now is 10:03 PM.