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 09-18-2011, 04:29 AM   #1
mdunicorn
LQ Newbie
 
Registered: Sep 2011
Posts: 6

Rep: Reputation: Disabled
configuration to run a cgi script


Hi,
I have a RHEL 4 server,
To run a cgi file that is located in the /var/www/html/speedtest directory I've added this configuration to the /etc/httpd/conf/httpd.conf file:
Code:
<Directory /var/www/html/speedtest>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
but I'm receiving Internal Server Error 500.
what's wrong?
thanks.

Last edited by mdunicorn; 09-18-2011 at 04:31 AM.
 
Old 09-18-2011, 10:12 AM   #2
kerrylinux
LQ Newbie
 
Registered: May 2009
Location: Co. Kerry, Ireland
Distribution: CentOS, Fedora, RedHat, Ubuntu Enterprise Cloud
Posts: 12

Rep: Reputation: Disabled
Quote:
Originally Posted by mdunicorn View Post
To run a cgi file that is located in the /var/www/html/speedtest directory I've added this configuration to the /etc/httpd/conf/httpd.conf file:
That's ok, but you'll need to setup a script alias:

Code:
ScriptAlias /speedtest/ "/var/www/html/speedtest"
 <Directory "/var/www/html/speedtest">
      AllowOverride None
      Options None
      Options FollowSymlinks ExecCGI 
      Order allow,deny
      Allow from all
</Directory>
Your script will be run with: http://yourservername/speedtest/scriptname


I hope that helps you.
 
Old 09-18-2011, 12:53 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Linux-Server and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 09-18-2011, 04:34 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
but I'm receiving Internal Server Error 500.
what's wrong?
You should check error_log to see why you get the 500 error

Regards
 
Old 09-19-2011, 06:19 AM   #5
mdunicorn
LQ Newbie
 
Registered: Sep 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kerrylinux View Post
That's ok, but you'll need to setup a script alias:

Code:
ScriptAlias /speedtest/ "/var/www/html/speedtest"
 <Directory "/var/www/html/speedtest">
      AllowOverride None
      Options None
      Options FollowSymlinks ExecCGI 
      Order allow,deny
      Allow from all
</Directory>
Your script will be run with: http://yourservername/speedtest/scriptname


I hope that helps you.

thank you kerrylinux,
I added your code but I receive the following error when I try to access to the speedtest dirctory

Code:
Forbidden
You don't have permission to access /speedtest/ on this server.
What should I do?
 
Old 09-19-2011, 07:02 AM   #6
centos123
Member
 
Registered: Apr 2011
Posts: 397

Rep: Reputation: 16
iam too getting same error in qmailadmin

when i browse as server-ip/qmailadmin iam getting list of all files and directories but when i moved qmailadmin dir to /var/www/cgi-bin/qmailadmin

it error

Forbidden

You don't have permission to access /cgi-bin/qmailadmin/ on this server.

what to do.access qmailadmin on browser

---------- Post added 09-19-11 at 07:03 AM ----------

can you tell me the path to check error_log
 
Old 09-19-2011, 07:13 AM   #7
cendryon
Member
 
Registered: Aug 2005
Location: France
Distribution: Slackware64 current
Posts: 82

Rep: Reputation: 30
Hi

You should check both filesystem permissions and owner with chmod and chown, and SELinux ACL as per
https://issues.apache.org/bugzilla/s...g.cgi?id=33504, comment 3.

Cheers
 
Old 09-19-2011, 11:34 PM   #8
mdunicorn
LQ Newbie
 
Registered: Sep 2011
Posts: 6

Original Poster
Rep: Reputation: Disabled
My SElinux is disabled and I have set all the permissions to 777.
I have a index.php in the speedtest directory that calls the cgi script.
I tested when I put the following line:
Code:
ScriptAlias /speedtest/ "/var/www/html/speedtest"
I get this error:
Code:
Forbidden
You don't have permission to access /speedtest/ on this server.
when I delete the ScriptAlias line, the cgi file shows in the browser instead of running!

What should I do?
 
Old 09-20-2011, 12:50 AM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by mdunicorn View Post
My SElinux is disabled and I have set all the permissions to 777.
I have a index.php in the speedtest directory that calls the cgi script.
I tested when I put the following line:
Code:
ScriptAlias /speedtest/ "/var/www/html/speedtest"
I get this error:
Code:
Forbidden
You don't have permission to access /speedtest/ on this server.
when I delete the ScriptAlias line, the cgi file shows in the browser instead of running!

What should I do?
The configuration in your 1st post
Quote:
<Directory /var/www/html/speedtest>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
was fine. To execute scripts from a directory other than the one defined with ScriptAlias, you need the AddHandler directive and the +ExecCGI option.
You should have looked in apache error_log to find the reason of the 500 error.
Anyway since you get the script code check if your cgi-script extension in included in the AddHandler directive

Regards
 
Old 09-20-2011, 07:53 AM   #10
kerrylinux
LQ Newbie
 
Registered: May 2009
Location: Co. Kerry, Ireland
Distribution: CentOS, Fedora, RedHat, Ubuntu Enterprise Cloud
Posts: 12

Rep: Reputation: Disabled
Quote:
Originally Posted by mdunicorn View Post
I tested when I put the following line:
Code:
ScriptAlias /speedtest/ "/var/www/html/speedtest"
I get this error:
Code:
Forbidden
You don't have permission to access /speedtest/ on this server.
when I delete the ScriptAlias line, the cgi file shows in the browser instead of running!

What should I do?
Sorry that I made a typo in my post. There must be a slash at the directory name as well.
Without it, the trailing slash in /speedtest/ gets lost in translation. That's why your webserver won't find the script.

The correct code is:
Code:
ScriptAlias /speedtest/ "/var/www/html/speedtest/"
Regards
 
  


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
Run My CGI Script from Webpage mykolg Linux - Server 6 01-17-2011 02:17 AM
How setup Apache to run CGI Script meligon Debian 1 11-29-2006 07:26 AM
Access forbidden when trying to run cgi script allan_y Linux - Software 4 10-07-2004 07:02 AM
Allow user to run their own cgi script samwong Linux - Newbie 5 05-25-2004 10:22 PM
Auto Run A Cgi Script f117bomb Linux - General 1 11-25-2001 01:18 AM

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

All times are GMT -5. The time now is 05:20 PM.

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