You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Prakash Premkumar <pr...@gmail.com> on 2015/07/07 13:58:22 UTC

You don't have permission to access /asd on this server

 I am using apache server version 2.4

I have installed apache to a custom location by specifying --prefix during
configure.

I'm on mac os x mavericks.

I am using apache module written in c. I'm following the tutorials at the
official sitehttp://httpd.apache.org/docs/2.4/developer/modguide.html

I installed module given under mod_example.c : The code is give below

/* Include the required headers from httpd */#include
"httpd.h"#include "http_core.h"#include "http_protocol.h"#include
"http_request.h"
/* Define prototypes of our functions in this module */static void
register_hooks(apr_pool_t *pool);static int
example_handler(request_rec *r);
/* Define our module as an entity and assign a function for
registering hooks  */

module AP_MODULE_DECLARE_DATA   example_module ={
    STANDARD20_MODULE_STUFF,
    NULL,            // Per-directory configuration handler
    NULL,            // Merge handler for per-directory configurations
    NULL,            // Per-server configuration handler
    NULL,            // Merge handler for per-server configurations
    NULL,            // Any directives we may have for httpd
    register_hooks   // Our hook registering function};

/* register_hooks: Adds a hook to the httpd process */static void
register_hooks(apr_pool_t *pool) {

    /* Hook the request handler */
    ap_hook_handler(example_handler, NULL, NULL, APR_HOOK_LAST);}
/* The handler function for our module.
 * This is where all the fun happens!
 */
static int example_handler(request_rec *r){
    /* First off, we need to check if this is a call for the "example" handler.
     * If it is, we accept it and do our things, it not, we simply
return DECLINED,
     * and Apache will try somewhere else.
     */
    if (!r->handler || strcmp(r->handler, "example-handler")) return (DECLINED);

    // The first thing we will do is write a simple "Hello, world!"
back to the client.
    ap_rputs("Hello, world!<br/>", r);
    return OK;}

I added my Set Handler as follows

<IfModule example_module>
    <Location /*>
        SetHandler example_module
    </Location>
</IfModule>

when I try to access localhost/ , I get "It Works!" screen.

But when I try to access some path in localhost like localhost/asd I get
the following error

Forbidden

You don't have permission to access /asd on this server. Server unable to
read htaccess file, denying access to be safe

Can you please help me solve this ?

Re: You don't have permission to access /asd on this server

Posted by Prakash Premkumar <pr...@gmail.com>.
Hi Eric,

I fixed the permission of the folder. Now I am able to access localhost/

But If i try to access other URL's like localhost/a
I get  The requested URL /a was not found on this server error.

In httpd.conf file.
I have set the following

>
> <IfModule example_module>
>     <LocationMatch ^/.*>
>         SetHandler example_module
>     </LocationMatch>
> </IfModule>


Can you please help me fix this ?

On Wed, Jul 8, 2015 at 6:10 PM, Eric Covener <co...@gmail.com> wrote:

> On Wed, Jul 8, 2015 at 8:31 AM, Prakash Premkumar
> <pr...@gmail.com> wrote:
> > The error log says
> >
> > (13)Permission denied: [client ::1:50441] AH00035: access to / denied
> >> (filesystem path '/Users/prakash-2282/Desktop/apache') because search
> >> permissions are missing on a component of the path
>
>
> Okay, pretty clear then. An alternative to fixing the permissions or
> pointing your DocumentRoot elsewhere is to implement a dummy
> translate_name or map_to_storage hook (I am not sure which one)
>
> --
> Eric Covener
> covener@gmail.com
>

Re: You don't have permission to access /asd on this server

Posted by Eric Covener <co...@gmail.com>.
On Wed, Jul 8, 2015 at 8:31 AM, Prakash Premkumar
<pr...@gmail.com> wrote:
> The error log says
>
> (13)Permission denied: [client ::1:50441] AH00035: access to / denied
>> (filesystem path '/Users/prakash-2282/Desktop/apache') because search
>> permissions are missing on a component of the path


Okay, pretty clear then. An alternative to fixing the permissions or
pointing your DocumentRoot elsewhere is to implement a dummy
translate_name or map_to_storage hook (I am not sure which one)

-- 
Eric Covener
covener@gmail.com

Re: You don't have permission to access /asd on this server

Posted by Prakash Premkumar <pr...@gmail.com>.
Hi Eric,

The error log says

(13)Permission denied: [client ::1:50441] AH00035: access to / denied
> (filesystem path '/Users/prakash-2282/Desktop/apache') because search
> permissions are missing on a component of the path


On Wed, Jul 8, 2015 at 5:57 PM, Eric Covener <co...@gmail.com> wrote:

> On Tue, Jul 7, 2015 at 7:58 AM, Prakash Premkumar
> <pr...@gmail.com> wrote:
> > You don't have permission to access /asd on this server. Server unable to
> > read htaccess file, denying access to be safe
> >
> > Can you please help me solve this ?
>
>
> What does the error_log say?
>
> --
> Eric Covener
> covener@gmail.com
>

Re: You don't have permission to access /asd on this server

Posted by Eric Covener <co...@gmail.com>.
On Tue, Jul 7, 2015 at 7:58 AM, Prakash Premkumar
<pr...@gmail.com> wrote:
> You don't have permission to access /asd on this server. Server unable to
> read htaccess file, denying access to be safe
>
> Can you please help me solve this ?


What does the error_log say?

-- 
Eric Covener
covener@gmail.com

Re: You don't have permission to access /asd on this server

Posted by Prakash Premkumar <pr...@gmail.com>.
Thanks for your reply Sorin.
I changed it to LocationMatch. But i still get the same error.

Can you please help me ?

On Wed, Jul 8, 2015 at 12:24 AM, Sorin Manolache <so...@gmail.com> wrote:

> On 2015-07-07 13:58, Prakash Premkumar wrote:
>
>>
>> I added my Set Handler as follows
>>
>> <IfModule example_module>
>>      <Location /*>
>>          SetHandler example_module
>>      </Location>
>> </IfModule>
>>
>> when I try to access localhost/ , I get "It Works!" screen.
>>
>> But when I try to access some path in localhost like localhost/asd I get
>> the following error
>>
>> Forbidden
>>
>> You don't have permission to access /asd on this server. Server unable to
>> read htaccess file, denying access to be safe
>>
>> Can you please help me solve this ?
>>
>
> I think the problem is not the code but the conf.
>
> <Location /*> does not match /asd. Check
> http://httpd.apache.org/docs/2.4/mod/core.html#location
>
> Use <LocationMatch ^/.*> instead.
>
> Sorin
>
>
>>
>

Re: You don't have permission to access /asd on this server

Posted by Sorin Manolache <so...@gmail.com>.
On 2015-07-07 13:58, Prakash Premkumar wrote:
>
> I added my Set Handler as follows
>
> <IfModule example_module>
>      <Location /*>
>          SetHandler example_module
>      </Location>
> </IfModule>
>
> when I try to access localhost/ , I get "It Works!" screen.
>
> But when I try to access some path in localhost like localhost/asd I get
> the following error
>
> Forbidden
>
> You don't have permission to access /asd on this server. Server unable to
> read htaccess file, denying access to be safe
>
> Can you please help me solve this ?

I think the problem is not the code but the conf.

<Location /*> does not match /asd. Check 
http://httpd.apache.org/docs/2.4/mod/core.html#location

Use <LocationMatch ^/.*> instead.

Sorin

>