After moving a file into the Linux HTTP directory, the file is not accessible

This is because of SELinux.

The issue is caused when you move something from one place to another. It preserves the SELinux context of the original when you move it. Therefore, if you download something into /home or /tmp it gets given an SELinux context that matches that location. If you move it to /var/www/html, it still has the context saying that it belongs in /tmp or /home and the policy says that httpd is not allowed to access those files.

If you copy the files instead of move them, the SELinux context gets assigned according to the location you’re copying to.

You can run ‘restorecon -r /var/www/html’, which fixes the context location, making the files accessible to the webserver.

Leave a Reply

Your email address will not be published. Required fields are marked *