1

I'm running the latest raspbian with latest updates and upgrades, and of course, apache2.4. I'm trying to access files and folders in /var/tmp/ but keep getting AH00128 file not found with error codes 404 and 496 in /var/log/apache2/access.log. In the browser, I simply get: File not found: The requested URL was not found on this server.

I've read many posts on the subject. I have a similar system running just fine on an older version of raspbian and apache2.2.

I have separate apache access and error files. I've set the log level to debug. But the log just says file not found. Since several things affect whether or not apache sees the file, this problem would be a lot easier for a lot of people to solve if apache told you why it thinks the file, which is clearly visible to root, is not present.

I'm not running selinux, as evidenced by the fact that the 'sestatus' command is not found.

Since apache2.4 runs as www-data, I executed the following to try to solve what appears to be a permissions problem:

chgrp -R www-data /var/tmp
chown -R www-data /var/tmp

I also updated /etc/apache2/sites-available/000-default.conf to use the proper apache2.4 format for directory blocks, and I put an alias in /etc/apache2/mods-enabled/alias.conf to alias /my_tmp/ to /var/tmp/. I restarted apache2 after making changes. I even tried using browsers on multiple PC's in case there was a cache issue.

No luck. I cannot get apache2 to access any files in /var/tmp/. I know my basic configuration is fine because I can access /var/www/html/phpinfo.php. I can also access files and folders in /usb via another alias. And, I have a script alias that is working fine, too.

ls -all /var gives:

drwx-xr-x www-data www-data

ls -all /var/tmp gives:

drwxrwsrwt www-data www-data

How do I fix this ? Thank you in advance for your help.

2 Answers 2

0

/tmp and /var/tmp are special directories which hold temporary files. Your system is likely resetting the ownership/permissions after each reboot, which effectively prevents you from changing these permanently. Should you succeed (e.g. by deactivating the corresponding tmpfs mountpoints, then changing the ownership), you may not be able to boot your system properly. And if your system boots, you may still end up exposing sensitive files, e.g. if you have /var/tmp/.X11-unix/xxx or /var/tmp/gdm-auth-cookies-xxx you usually don't want to share those with the whole world.

You should really consider moving the files you want to share to /var/www/html, which is there exactly for this purpose.

0

I found the problem. It's systemd, which makes private tmp folders by default. So apache was not accessing the /var/tmp folder I thought it was. Once systemd PrivateTmp is disabled, the systemd daemon restarted, and apache2 restarted, the system works as desired.

I use /var/tmp because this is an IoT system, not a conventional web site. Most of the files being accessed by apache have very short lifetimes, 15 seconds or so, and are created constantly. Some files change several times per second -- definitely temporary files. Since the disk is a flash memory with limited life, /var/tmp gives me a RAM disk that does not wear out with such heavy and frequent use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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