• Blogs (9)
    • šŸ“± 236 - 992 - 3846

      šŸ“§ jxjwilliam@gmail.com

    • Version: ā€šŸš€ 1.1.0
  • Apache 403 Forbidden Error and Solution

    Blogs20102010-12-01


    The Apache 403 Forbidden Error is quite normal: A 403 status code indicates that the client cannot access the requested resource. It means the permissions on the server do not allow what was being asked. If found this error, there are several ways to do quick fix.

    (1) Accessible: privilege issue
    For the web scripts (php or perl or whatever) in Linux:

    • for php script
      php interpreter (/usr/bin/php) needs the privilege to access and parse it, so make sure the php script is accessible and readable;
      Normally the directory (which hold php scripts) should have the privilege '775' and the php script file itself is '664'.

    • for perl cgi script
      Make sure the perl script is executable: normally the directory (which hold php scripts) should have the privilege '775' and the php script file itself is '775'.
      perl cgi is running by itself: in the first line of the perl cgi, is its shabang:
      #! /usr/bin/perl
      When executing, this command line forks a process to execute itself - the cgi process.

    (2) httpd.conf

    Usually for easy setup and access web application, I use a lot of aliases in httpd.conf, e.g.:
    Alias /test "c:...desktopwilliamprojectstest"
    This maybe the simplest way to locate a web application in httpd.conf:
    http://localhost/test/
    This kind of configuration is easy and convenient. However make sure to configure it correctly.
    There are 2 level of previlege assignment in httpd.conf:

    (A) root dir:
    The DOCUMENTROOT default can't be access, in the local machine, we'd better to change the previlege like this:

          <Directory />
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride None
          Order deny,allow
          Allow from all
          </Directory> 

    (B) individual dir:
    Instead of above settings globally, the following just setup the privilege for '/test':

          <Directory /test>
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride None
          Order deny,allow
          Allow from all
          </Directory>
    Either of these 2 ways makes http://localhost/test/ work fine.

    (3) make the interpreter searchable.

    e.g., in Windows, if php.exe is not at the %PATH% env variables, the 403 error occurs. So double check php is available in the %PATH%:

    Conrol Panel -> Advanced System settings -> Advanced -> Environment Variables -> System variables-> path:
    path=%PATH%;C:xamppphp;
    The interpreter php.exe is searchable, so the 403 issue is fixed.

    (4) Make sure you have permission to use .htaccess file for Apache web server.
    If Apache has overrides disabled. you will bump back with a 403 error.

    The above solved my most 403 issues.