0

I'm trying to change the default Apache root location /var/www/html to /mnt/datos/mylocation. I also tried to /home/[MY USER]/mylocation, thinking it was related to mounted partition permissions.

  • I tried using root:root, www-data:www-data and [MY USER] as /mnt/datos/mylocation's owner,
  • I tried multiple locations (bc I had doubts about permissions).
  • I created an empty .htaccess file.
  • I even gave 777 to everything (just to test, I know it's bad).
  • Sites are enabled in Apache config.
  • Apache was restarted to apply changes.

when I load localhost or NNNNN.local it shows:

Forbidden
You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe
Apache/2.4.52 (Ubuntu) Server at localhost Port 80

WHAT IS MISSING???

My current files are as following:

/etc/apache2/apache.conf

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerName NNNNN.local
    ServerAlias NNNNN.local
    DocumentRoot /mnt/datos/mylocation
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Fahed
  • 121
  • 1
  • 9
  • Is SELinux enabled? Check for errors: `journalctl -xe`. SELinux will, by default, prevent httpd from accessing files outside of the standard `/var/www/` path. – JG7 Sep 25 '22 at 22:21
  • I got this: `$ sestatus SELinux status:disabled` ; `$ getenforce Disabled` – Fahed Sep 26 '22 at 05:54
  • Did you apply the chmod to the top directory as well, or just the files ? – SBO Sep 26 '22 at 06:35
  • 1
    This might help https://askubuntu.com/questions/337874/change-apache-document-root-folder-to-secondary-hard-drive – asktyagi Sep 26 '22 at 08:31
  • @SBO applied it to everything up to tthe filess I need to serve. – Fahed Sep 27 '22 at 01:49
  • @asktyagi thanks, but n fact I did followed thee instructions on that question too. – Fahed Sep 27 '22 at 01:52

0 Answers0