title: How does one grant apache2 access to files hosted under a secondary partition?
body: <p>I am having an issue with my apache configuration, whereby the web browser throws up a 403: Forbidden error when trying to access a symlinked resource that resides on a secondary partition.</p>
  
  <p>I am aware that there are two key components that need to be in place in order to circumvent a garden-variety 403 error:</p>
  
  <ol>
  <li>Symlinks must be enabled in an apache config file. (<code>/etc/apache2/sites-available/000-default.conf</code> or <code>/etc/apache2/apache2.conf</code>).</li>
  <li>The apache2 linux user account, <code>www-data</code>, must have permissions that are strong enough to let it read, write, execute the files within the symlinked directory, and the directories leading up to said directory.</li>
  </ol>
  
  <p>I have enabled symlinks, but I am having trouble with an aspect of the permissions configuration.</p>
  
  <p>In regards to 1., I am using the following syntax to enable symlinks (and configure the root directory):</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin webmaster@localhost
      DocumentRoot /var/www
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
      &lt;Directory "/var/www"&gt;
          Options Indexes FollowSymLinks MultiViews Includes ExecCGI
          AllowOverride All
          Require all granted
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>I have verified that symlinks are working:</p>
  
  <p>I have placed a symlink within <code>/var/www/</code>, named <code>home-apache</code>, which points to <code>/home/kohl/kohl/srv/apache</code>. Within <code>/home/kohl/kohl/srv/apache</code>, I have a file named <code>test.html</code>. When I visit <code>localhost/home-apache/test.html</code>, I can access the file.</p>
  
  <p>In other words, <code>var/www/home-apache/test.html</code> is pointing to <code>/home/kohl/kohl/srv/apache/test.html</code>, and by virtue of the apache configurating establishing the root at <code>/var/www</code>, I can access the webpage by typing <code>localhost/home-apache/test.html</code> in the browser.</p>
  
  <p>However, this only works because the actual test.html file resides on the main partition - the same partition as <code>/var/www</code>.</p>
  
  <p>If I repeat the test, but simlink the file <code>/media/kohl/artemis/test/secondary-drive-test.html</code> to <code>/var/www/home-apache/secondary-drive-test.html</code>, and visit <code>localhost/home-apache/secondary-drive-test.html</code>, (note that the actual file now resides on the secondary partition, <code>artemis</code>) I get a 403.</p>
  
  <p>I believe that this problem is caused by the fact that <code>www-data</code> is unable to access '/media/kohl'. I can verify this noting the output of <code>sudo -u www-data ls -la /media/kohl/</code>, which is <code>ls: cannot open directory '/media/kohl/': Permission denied</code>.</p>
  
  <p>However, attempts to change permissions of the directory, thus rectifying the problem, are futile.</p>
  
  <p>After running <code>sudo chmod 777 /media/kohl</code>, and then re-running <code>sudo -u www-data ls -la /media/kohl/</code>, I still get the same <code>Permission denied</code> message - despite a normal <code>ls -la</code> revealing permissions of the /media/kohl directory to be omnilenient - <code>drwxrwxrwx</code>. For good measure, I have also added the <code>kohl</code> user to the <code>www-data</code> group and vice-versa.</p>
  
  <p>I am a bit of a loss in trying to understand what I should do to get this to work.</p>
  
  <p>The secondary partition is an ext4 partition, and is mounted at boot-time through fstab. None of the drives are encrypted.</p>
  
  <p>Interestingly, it worked fine before when I was using slightly different software. The problem only came about since upgrading to Linux Mint 19.2 (Ubuntu 18.04.3), and Apache 2.4.</p>
  
  <p>Any help in solving this conundrum would be greatly appreciated. Please note that this is only a development environment.</p>