LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-28-2012, 03:54 AM   #1
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Rep: Reputation: Disabled
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 ?
 
Old 11-29-2012, 09:22 AM   #2
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Bump.
I cant believe noone uses httpd server and / or CGI. Need urgent help with this.
 
Old 11-30-2012, 10:05 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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
 
Old 12-04-2012, 05:48 AM   #4
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
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.

Last edited by Roboserg; 12-04-2012 at 05:51 AM.
 
Old 12-04-2012, 05:53 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Roboserg View Post
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.
 
Old 12-04-2012, 09:32 AM   #6
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
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

Last edited by jsaravana87; 12-04-2012 at 09:43 AM.
 
Old 12-04-2012, 10:12 AM   #7
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by arun5002 View Post
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
 
Old 12-05-2012, 02:28 AM   #8
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.

Last edited by Roboserg; 12-05-2012 at 02:29 AM.
 
Old 12-05-2012, 03:06 AM   #9
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
Whats going on oO
 
Old 12-06-2012, 02:14 AM   #10
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
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
 
Old 12-06-2012, 04:10 AM   #11
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
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"
 
Old 12-06-2012, 04:16 AM   #12
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by Roboserg View Post
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"
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.
 
Old 12-06-2012, 05:47 AM   #13
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
"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".
 
Old 12-06-2012, 06:11 AM   #14
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
I'm stumped then, suggest you raise this on a Busybox forum?
 
Old 12-06-2012, 06:20 AM   #15
Roboserg
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
I'm stumped then, suggest you raise this on a Busybox forum?
It may sound stupid but I didnt found any busybox official forums ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant seem to run any cgi scripts in cgi-bin folder, confused? j.smith1981 Linux - Server 5 02-14-2011 05:38 AM
C server & CGI scripts [python] meisterluv Programming 5 04-04-2010 11:23 AM
CGI scripts - Persistent Server 500 errors DLHOMME Linux - Networking 9 05-22-2006 02:56 PM
CGI scripts - Persistent Server 500 errors DLHOMME Linux - Networking 1 05-19-2006 07:56 AM
Apache Web Server and CGI scripts jonty_11 Red Hat 2 05-17-2006 01:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration