4

I have apache 2.4 on my raspberry pi and need to change DocumentRoot to flash drive folder. But I have 403 Forbidden.

In apache logs:

AH01630: client denied by server configuration: /media/pi/www/html/

and

AH00035: access to /index.html denied (filesystem path '/media/pi/www') because search permissions are missing on a component of the path

I have read article on apache site for this error and make chmod like this, but it still forbidden:

root@raspberrypi:/etc/apache2/sites-available# namei -m /media/root/www/html/index.php
f: /media/root/www/html/index.php
 drwxr-xr-x /
 drwxr-xr-x media
 drwxr-xr-x root
 drwxr-xr-x www
 drwxr-xr-x html
 -rw-r--r-- index.php

Domian config:

<VirtualHost *:80>
    <Directory "/media/root/www">
        AllowOverride All
        Require all granted
    </Directory>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /media/root/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

If change to origin /var/www - all works fine.

1 Answers1

0

Problem with virtual host config file. I am changing the default file only one line change is there...

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        #DocumentRoot /var/www/html
        DocumentRoot /media/root/www/html
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

DocumentRoot /media/pi/www/html should be changed to your location which is DocumentRoot /media/root/www/html/

Also never forget to give permission to apache.

sudo chown www-data:www-data /media/root/www/html/ -R
rajesh6115
  • 176
  • 4