2

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.

  • What is the filesystem on the flash drive? – techraf Jan 31 '17 at 12:14
  • What are the group and owner set to for files on the flash drive ? ls -l /media/root/www/html ? Also check that the flash drive is not mounted read-only – KennetRunner Jan 31 '17 at 12:16
  • @techraf I tried with FAT32 first, this fs don't support premissions. Then I try ext4. – Nikita Sidorov Jan 31 '17 at 13:21
  • @KennetRunner ls -l /media/root/www/html -rw-r--r-- 1 www-data www-data 20 янв 26 18:55 index.php -rw-r--r-- 1 www-data www-data 5 янв 26 18:56 text.txt – Nikita Sidorov Jan 31 '17 at 13:24
  • mount | grep "media" ? – KennetRunner Jan 31 '17 at 14:26
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
  • Sorry, I have pasted old config. I have updated it now. All is well with path, but still not working. – Nikita Sidorov Jan 31 '17 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.