LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cgi-bin always has 404 error (https://www.linuxquestions.org/questions/linux-newbie-8/cgi-bin-always-has-404-error-4175647891/)

indraindrajit71 02-08-2019 11:12 AM

cgi-bin always has 404 error
 
Hello

I am trying to access a cgi script via an html page.
But it gives 404 error every time.


Not Found

The requested URL /EF="cgi-bin/test.cgi" was not found on this server.



##my html page##
test.html
<A HREF=EF="cgi-bin/test.cgi"> Click here to run a CGI program</A>



<VirtualHost *:80>
ServerName www.example.com


DocumentRoot "/var/www/cgi-bin/"


<Directory "/var/www/cgi-bin/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>

## Logging
ErrorLog "/var/log/httpd/error.log"
ServerSignature Off
CustomLog "/var/log/httpd/access.log" combined
## Script alias directives
ScriptAlias /cgi-bin "/var/www/cgi-bin/"
</VirtualHost>



PS: the permissions of the html file is:
-rwxr-xr-x. 1 apache apache 67 Feb 8 22:28 test.html


-rwxr--r--. 1 apache apache 390 Feb 7 00:30 test.cgi



also note that if I run the cgi-bin/test.cgi directly from browser,it works fine.


Please help !

scasey 02-08-2019 11:34 AM

Quote:

Originally Posted by indraindrajit71 (Post 5959466)
Hello

I am trying to access a cgi script via an html page.
But it gives 404 error every time.


Not Found

The requested URL /EF="cgi-bin/test.cgi" was not found on this server.



##my html page##
test.html
<A HREF=EF="cgi-bin/test.cgi"> Click here to run a CGI program</A>

That's a pretty clear error message! Your <a> tag is not correct. It should be:
Code:

<A HREF="cgi-bin/test.cgi"> Click here to run a CGI program</A>
Why did you put the EF= in the href? It's obviously not in the url.

TB0ne 02-08-2019 11:37 AM

Quote:

Originally Posted by indraindrajit71 (Post 5959466)
Hello
I am trying to access a cgi script via an html page. But it gives 404 error every time.
Code:

Not Found
The requested URL /EF="cgi-bin/test.cgi" was not found on this server.

##my html page##
Code:

test.html
<A HREF=EF="cgi-bin/test.cgi"> Click here to run a CGI program</A>

Code:

<VirtualHost *:80>
  ServerName www.example.com
  DocumentRoot "/var/www/cgi-bin/"
  <Directory "/var/www/cgi-bin/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
  </Directory>

  ## Logging
  ErrorLog "/var/log/httpd/error.log"
  ServerSignature Off
  CustomLog "/var/log/httpd/access.log" combined
  ## Script alias directives
  ScriptAlias /cgi-bin "/var/www/cgi-bin/"
</VirtualHost>

PS: the permissions of the html file is:
-rwxr-xr-x. 1 apache apache 67 Feb 8 22:28 test.html
-rwxr--r--. 1 apache apache 390 Feb 7 00:30 test.cgi

also note that if I run the cgi-bin/test.cgi directly from browser,it works fine.

Please put your configs/files in CODE tags. And did you read and think about what you posted??? You have the document ROOT set to be /var/www/cgi-bin (which is a bad idea), then your web page calls 'cgi-bin/test.cgi'. Meaning that you would need a /var/www/cgi-bin/cgi-bin path. Also, you need to check the syntax on calling that 'web page', as you may need to modify your path (such as './test.cgi' or the like.) And your HREF tag is wrong...why the extra EF?

:: EDIT :: scasey beat me to it.

indraindrajit71 02-08-2019 12:35 PM

1 Attachment(s)
thanks much to both gentleman !

made changes in httpd.conf

DocumentRoot "/var/www/html/test.html"
<Directory "/var/www/html/">

and it works perfectly.

Another help which I would like to have is:
I added another cgi script in the html but the output is bit closer (both tabs) when fired from browser.Meaning I wanted to have the tabs both in vertical position with bit of space.since I need to have at-least 10-20 different CGI's with separate links that's why needed this.later I will try to make the looks of that page look bit attractive by reading blogs or steps.
sorry for the ask but this is really killing me.


cat test.html
<A HREF="cgi-bin/test.cgi"> Click here to run a CGI program</A>
<A HREF="cgi-bin/test2.cgi"> nova listing of VM</A>

scasey 02-08-2019 03:04 PM

Put each anchor tag in paragraph <p> tags
Or
Separate them with <br> tags

Please search for “html syntax”

indraindrajit71 02-09-2019 05:47 AM

thanks to both of you.


closing this thread !


All times are GMT -5. The time now is 02:12 AM.