0

I have a web app in which users can see image and videos. But I'm always getting 403 Permission denied when I tried to see any image or video.

I checked the permission of the file and it's

drwxrwxrwx.   2 apache apache  4096 Jul 12 09:57 ads
drwxrwxrwx.   5 apache apache  4096 Jul 12 09:58 img
drwxrwxrwx.   3 apache apache  4096 Jul 12 09:58 programs
drwxrwxrwx.   2 apache apache  4096 Jul 12 09:58 seassons
drwxrwxrwx.   2 apache apache  4096 Jul 18 08:34 temp
drwxrwxrwx. 374 apache apache 24576 Jul 18 08:34 videos

I'm trying to open the image in those folders in a web browser when the server is httpd.

If I run the following commands everything start working but for EXISTING files... If a user upload a new file, that will get 403 again until I run again the commands.

sudo chmod -R g+r /videos
sudo chown -R apache /videos

And my httpd.config is

<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted

Further relax access to the default document root:

Options Indexes FollowSymLinks AllowOverride All Require all granted

My OS is Centos7

The new files are created with the following permissions:

-rw-r-----. 1 tomcat tomcat 386688 Jul 18 09:14 mynewfile
Cœur
  • 37,241
  • 25
  • 195
  • 267
Faabass
  • 1,394
  • 8
  • 29
  • 58

1 Answers1

0

Your apache process can't access the files because of the permissions set when it's created, so you need to change this. I don't know why your new files' owner/group is set to Tomcat - that's got to be the user that some process is running as (not Apache?). To set permissions on newly created filesna directory look at theumask command - this sets permissions on newly created files in the current directory. Try umask 022 in each directory to set default permissions to user writeable, world readable.

Jim ReesPotter
  • 445
  • 1
  • 3
  • 10