0

I am here because I have a very strange behaviour on my server and I ever investigate for hours on the AH00035 error.

On my server, if I create a simple php file index.php

<? php echo "Hello world" ?>

I can reach it.

When I use the exact same file uploaded by sftp, I get the AH00035 error. But when I copy the file, and apply the exact same permissions and user group than before, I don't have the error anymore.

Here is the scenario :

1 - Upload of the files using sftp

2 - Check the permissions of the file

-rw-r--r--.  1 SFTP_JOR_USER sftp_users index.php

3 - Mooving the file to my html directory

4 - Trying to access to the file : AH00035

5 - Changing users

 chown apache:apache index.php

6 - Trying to access the file : AH00035

HERE THE STRANGE PART

7 - Copying the file

cp index.php index2.php

8 - checking permission

-rw-r--r--.  1 root   root index2.php

9 - Accessing index2.php : Hello world (NICE !)

10 - Trying to make index.php on root

chown root:root index.php

11 - Trying to access index.php : AH00035

12 - Changing index.php and index2.php users

chown apache:apache index.php
chown apache:apache index2.php

So, finally, I have the EXACT SAME FILE, with EXACT SAME CONTENT and EXACT SAME PERMISSION.

One cause an AH00035 error. The other one is accessible.

I really don't understand what happens here. Is it because of uploading them by sftp ???

I really don't want to make a copy of my files, then rename them, then change user group every time I make a change on my development.

Thanks in advance

Snite
  • 3
  • 3

1 Answers1

0

You moved the original file from your home directory to the web directory instead of copying it, thus the SELinux context of the file is wrong. When you move a file, its SELinux context is preserved by default.

You can resolve this in any of these ways:

  1. Copy the file from your home directory to the web directory (then delete the original if desired). The new file will have the different SELinux context.
  2. Move the file with mv -Z to reset the SELinux context to the default for the destination.
  3. Upload the file with SFTP directly to its destination directory instead of your home directory.
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • God, it was working before and I used the cp command, I wanted to use the mv command to prevent me to delete the files from the SFTP upload folder... Very instructive, thank you for your fast answer ! Genius ! – Snite Jan 27 '21 at 13:09