Access forbidden 403 error in xampp

I am very new to xampp. I have made a fresh xampp install with the following commands.

sudo su
cd /tmp
wget bit.ly/1cmyrUo -O xampp-32bit.run
chmod 777 ./xampp-32bit.run
sudo ./xampp-32bit.run

Then I made a perl file to check whether my xampp works. The following is my sample.pl file content.

#!usr/bin/perl
print "content-type:text/html\n";
print(header());
use CGI qw(:standard);
print(start_html());
print "Hello. I am ram";
print(end_html());

After copying my perl file from /home/vicky/desktop to /opt/lampp/cgi-bin.

I started my xampp with the following command.

/opt/lampp/lampp start

Then I ran my sample.pl in the localhost with the help of the http://localhost/cgi-bin/sample.pl in my mozilla browser. I just got the following window. Error 403 window

I found only answers relating to the 'new security concept error' and 'accessing virtual host issue'.

I did came across an askubuntu query, a bid similar to that of mine. It had no answers but some comments. One comment suggested to change the file permissions. It directed to get help from here.

It said to change the directory permission as 755 and file permission as 644 to resolve this kind of issue. When I tried to do that, I came to know that my cgi-bin directory already had 755 permission and my sample.pl had 644 permission. I have no solutions now.


PostScript: I have attached the content of my /opt/lampp/apache2/conf/httpd.conf file. Hope this will help the answer-providers to understand my problem completely.

Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"

<Directory "/opt/lampp/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory> 

As I can see in your question, you are using Apache 2.4.7, but your httpd.conf use Apache 2.2 directive.

According to Apache 2.4 manual:

Access control

In 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.

In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host. The old access control idioms should be replaced by the new authentication mechanisms, although for compatibility with old configurations, the new module mod_access_compat is provided.

Try this changes:

<Directory "/opt/lampp/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory> 

Allow and deny directive controls which hosts can or can't access an area of the server, Require tests whether an authenticated user is authorized according to a particular authorization provider and the specified restrictions. Require all granted means access is allowed unconditionally, let see Beyond just authorization

Update after reading configuration file:

Your default configuration file is right. The problem is wrong shebang in perl script.

Try this:

  #!/usr/bin/perl

Also:

  chmod +x /opt/lampp/cgi-bin/yourScript.pl

Here is a useful link about file permission problem

Second update

Change http content header:

  print "Content-type:text/html\n";

This header is read by apache.

You apache is running as daemon user, check if each directory in script path are readable.