Access forbidden 403 error in xampp

41,391

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.

Share:
41,391

Related videos on Youtube

Ramvignesh
Author by

Ramvignesh

Updated on September 18, 2022

Comments

  • Ramvignesh
    Ramvignesh over 1 year

    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> 
    
    • kraxor
      kraxor over 9 years
      I'd suggest using sudo apt-get install lamp-server^ instead of installing xampp manually.
    • Lety
      Lety over 9 years
      403 forbidden means that your are not allow to access that page. Could you post your apache configuration? Also try this link
    • Ramvignesh
      Ramvignesh over 9 years
      @Letizia: Where is my apache configuration?
    • Lety
      Lety over 9 years
      @Ranviqnesh: should be in the directory /your/path/xampp/apache/conf
    • Lety
      Lety over 9 years
      Did you post the entire file or only a portion? Could you check if there are other file in /opt/lampp/apache2/conf or in /opt/lampp/apache2/sites-available. If you find 00-default.conf, could you post its content? You could use pastebin.
    • Ramvignesh
      Ramvignesh over 9 years
      @Letizia: Yes. I did had just this much in my httpd.conf file. Then, I don't have sites-available. As well, I don't have 00-default.conf anywhere.
  • Ramvignesh
    Ramvignesh over 9 years
    New changes does show the same error message!
  • Lety
    Lety over 9 years
    So there must be other configuration files, is there /opt/lampp/etc/extra/httpd-xampp.conf file? Try find /opt/lampp -name "*.conf" and check if these file are apache conf file
  • Ramvignesh
    Ramvignesh over 9 years
    I have found /opt/lampp/etc/extra/httpd-xampp.conf. But there is no <Directory "/opt/lampp/apache2/htdocs"> section. I have attached my httpd-xampp.conf file here. Please see through it.
  • Lety
    Lety over 9 years
    @Ramviqnesh: okey, this file is a part of configuration, I think that there are other file, in any case, did you get same error if you try to access a simple index.php at localhost?
  • Ramvignesh
    Ramvignesh over 9 years
    It is not showing any error. When I enter http://localhost/index.php, the url turns into http://localhost/xampp/. Then, the XAMPP for Linux page is getting opened.
  • Lety
    Lety over 9 years
    Thi means that there is an http redirection. It is necessary find out the main apache configuration file. Try this command: 'find /opt/lampp -name "*.conf" -exec grep DocumentRoot {} \; -print'
  • Ramvignesh
    Ramvignesh over 9 years
    I have tried find /opt/lampp -name "*.conf" -exec grep DocumentRoot {} \; -print. And I have pasted its result here. Please look through it.
  • Lety
    Lety over 9 years
    Could you post: /opt/lampp/etc/httpd.conf and /opt/lampp/etc/extra/httpd-vhosts.conf? And also "ls /opt/lampp/etc /opt/lampp/etc/extra" output.
  • Ramvignesh
    Ramvignesh over 9 years
  • Ramvignesh
    Ramvignesh over 9 years
    Changed my shebang and done +x to the file permissions. Still I find the 403 error.
  • Lety
    Lety over 9 years
    @Ramvignesh, I'm curious, did you finally resolve the issue?
  • Ramvignesh
    Ramvignesh over 9 years
    Sorry ya. My brother mistakenly overwritten my ubuntu os with a windows 8. I have installed a new copy of ubuntu now. need to install xampp again.
  • Ramvignesh
    Ramvignesh over 9 years
    When I installed xampp last time, I did it this way. Shall do the same now ?
  • Lety
    Lety over 9 years
    Sorry, but I don't know, If you need help on how is the best way to install xampp, try to ask an other question, someone else will help you for sure.
  • Nhat Nguyen
    Nhat Nguyen about 8 years
    and configure--> httpd.conf <Directory "/opt/lampp/apache2/htdocs"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
  • Oli
    Oli about 8 years
    Allowing read+write+execute to every user is a bad idea.