I'm migrating from Apache 2.2 to 2.4 and can no longer access files that are not in document root -- a classic alias problem. I have read many conflicting posts about this and made changes recommended by the official Apache doc regarding the use of alias, but it's still not working. I have set logging levels to the most verbose, namely debug in /etc/apache2/sites-enabled/000-default.conf and /etc/apache2.conf to try to solve the problem.

I have a web page that tries to access foo.txt on /var/tmp on each of two machines. I can access it just fine using 2.2 but I get an error, The requested URL was not found on this server, with 2.4. I'm using an alias in /etc/apache2/sites-enabled/default.conf on 2.2 and 000-default.conf on 2.4, to access that folder, and I've defined that folder in a directory block.

I'm using this in 2.4's 000-default.conf:

''' <VirtualHost *:8000> ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    <Directory /var/tmp/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
            Header set Access-Control-Allow-Origin "*"
    Alias /Dummy/ /var/tmp/
    LogLevel debug

I thought the problem might be permissions since it is often an issue. On the 2.2 machine, I have just root root on the folder and it works fine (ls -all -d /var/tmp):

drwxrwxrwt 6 root root 2200 Oct 24 16:41 /var/tmp

and (ls -all /var/tmp/foo.txt):

-rw-r--r-- 1 root root 805 Oct 24 16:42 foo.txt

to the file I'm trying to access in that folder.

Since that didn't work on the machine with 2.4, I tried this for the folder:

drwxrwxrwt 9 www-data www-data 1440 Oct 24 16:44 /var/tmp

and this on the file that I'm trying to access in that folder:

-rw-r--r-- 1 www-data www-data 836 Oct 24 16:45 foo.txt

The first example works fine with 2.2 but the second example fails with 2.4, giving me:

Not Found. The requested URL was not found on this server.

In /var/log/apache2/access.log I get:

IP address - - [24/Oct/2020:16:47:02 -0400] "GET /Dummy/foo.txt HTTP/1.1" 404 497 "-" "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

In /var/log/apache2/error.log I get:

''' [Sat Oct 24 16:52:01.154485 2020] [authz_core:debug] [pid 32675] mod_authz_core.c(820): [client IP address:34306] AH01626: authorization result of Require all granted: granted

[Sat Oct 24 16:52:01.155003 2020] [authz_core:debug] [pid 32675] mod_authz_core.c(820): [client IP address:34306] AH01626: authorization result of : granted

[Sat Oct 24 16:52:01.155659 2020] [core:info] [pid 32675] [client IP address:34306] AH00128: File does not exist: /var/tmp/foo.txt '''

The URL I'm using is:


I tried leaving the trailing / off the alias, and I got a permission error instead of not found, so I restored the trailing /. I restarted apache2 after each change to a config file.

Yes, the target file is really there. I have not touched the default .htaccess file.

How can I fix this ???


I suspect you are not only changing to apache 2.4 but that apache 2.4 is run by systemd and the apache2.service systemd file contains PrivateTmp=true Which means, it will have its own /tmp and /var/tmp separate from the system (see SYSTEMD.EXEC(5)).

The /var/tmp seen by apache will actually live at /var/tmp/systemd-private-<long hash>-apache2.service-f00WPn/tmp

The solution is to either disable that directive or to place the files at a different folder. If the files are created by another daemon, you could use JoinsNamespaceOf= directive to have both share the same /tmp and /var/tmp

  • Thank you. I found the apache2 systemd file in /lib and copied it to the /etc/systemd/system folder. I set PrivateTmp=False and restarted both apache2 and the apache2 service. But I still get Not Found when I try to access files in /var/tmp. I have other aliases that point to other folders, and they work, so my basic setup is ok. I don't understand how to make the other change you mentioned. How do I fix this ?
    – NewtownGuy
    Oct 25 '20 at 0:29
  • @NewtownGuy did you copy it on the right place? I have /etc/systemd/system/multi-user.target.wants/apache2.service being a symlink to /lib/systemd/system/apache2.service so if you copied it somewhere else, an entry like that could still be in effect. Also, you will need systemctl daemon-reload to ensure the change of the unit file takes effect.
    – Ángel
    Oct 25 '20 at 1:09
  • Yes. I copied /lib/systemd/service/apache2.service to /etc/systemd/service and edited it there. Other than rebooting, is there another way to do daemon-reload ? I have current Buster OS with latest updates, but I don't have the systemctl command and cannot find it with apt-get.
    – NewtownGuy
    Oct 25 '20 at 1:25

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.