Apache 403 Error - where is the fault?

11,317

Have you checked that www-data can read each of the dirs in the path? start at the top level dir and work your way down.

Share:
11,317

Related videos on Youtube

fabjoa
Author by

fabjoa

Updated on September 18, 2022

Comments

  • fabjoa
    fabjoa almost 2 years

    My environment: Ubuntu 10.10 Desktop Edition

    So I am trying to access a file through my localhost and Apache is giving me a 403 error.

    On /etc/apache2/apache2.conf, I've added this line :

    # wan27 hostel
    Include "/home/francoisrv/Ubuntu One/hostel/apache2.conf"
    

    The contents of /home/francoisrv/Ubuntu One/hostel/apache2.conf:

    Alias /hostel "/home/francoisrv/Ubuntu One/hostel/"
    
    <Directory "/home/francoisrv/Ubuntu One/hostel/">
    
    DirectoryIndex index.php
    
    Options +FollowSymLinks
    AllowOverride All
    
    order deny,allow
    deny from all
    allow from 127.0.0.0/255.0.0.0 ::1/128
    # allow from all
    
    <IfModule mod_php5.c>
      php_flag magic_quotes_gpc Off
      php_flag track_vars On
      php_value include_path .
    </IfModule>
    
    </Directory>
    

    Then make sure folder is accessible to www-data, on my terminal:

    chown -R www-data "/home/francoisrv/Ubuntu One/hostel"
    

    Then restart Apache, Apache does not complain about some misconfiguration

    /etc/init.d/apache2 restart
     * Restarting web server apache2                                                                                           ... waiting                                                                                                       [ OK ]
    

    Then, on Chrome, entering address http://localhost/hostel/checkin.php, I get:

    403
    Forbidden
    
    You don't have permission to access /hostel/checkin.php on this server.
    
    Apache/2.2.16 (Ubuntu) Server at localhost Port 80
    

    The contents of /home/francoisrv/Ubuntu One/hostel/checkin.php:

    hola
    

    What am I missing?

    • rvs
      rvs over 13 years
      What's is apache error log? Also, I don't see virtualhost entry, could you share it? It might be relevant.
    • fabjoa
      fabjoa over 13 years
      Having a look at /var/log/apache2/error.log I see this line: [Tue Mar 29 09:34:15 2011] [error] [client 127.0.0.1] (13)Permission denied: access to /hostel/checkin.php denied. Now a question about the file: it should be /home/francoisrv/Ubuntu One/hostel/checkin.php and not /hostel/chekin.php, but in this case log should show a Not found error instead of Permissions denied ?...
    • fabjoa
      fabjoa over 13 years
      @rvs are you talking about the virtual host conf file?
    • fabjoa
      fabjoa over 13 years
      Also, I've tried to move the hostel folder somewhere else and same issue :(
    • fabjoa
      fabjoa over 13 years
      Now I've moved the hostel folder to the root / and it works ?! Could it be that placing a file in the Ubuntu One folder not the best idea?
  • Frands Hansen
    Frands Hansen over 11 years
    This isn't really fit as an answer. Please xplain your entire answer rather than just referring to a comment.