Misunderstanding about apache and permissions - apache

I'm configuring a server from scratch. I'm stuck in front of write permissions.
I'm trying to install a Magento installation and when I do the wizard I'm stuck in front these errors :
Path "/var/www/html/magento2/app/etc" must be writable.
But, when I go to ssh,
ls -l in /var/www/
drwxrwxrwx. 4 root apache 124 29 déc 14:21 html
(ed1: Previously I did chmod 777 -R html/)
(ed2: I'm on local server so, 777 rights are fine, don't blame me about it).
I install VSFTPD and I can upload files by FileZilla without problems.
I think, I have no enough rights only when I try through a browser. I looked into apache configuration, I set all to Require all granted and AllowOverride All. But I am still stuck.
Someone has already been in front of this case ? I'm sure, the solution is easy but I miss understand something about apache permissions.
PS : I'm working on my local machine with virtualBox on CentOs 7
PPS : My local virtual machine has 2 networks cards and is connected to Internet.

Related

apache subprocess can't access files

i'm running into a problem where a program written to be accessed as a web service can't access anything in the local file system. running the program from the command line works correctly, but fails when called via apache as a subprocess exec'd via system() from a php script ; it simply can't find the files it's supposed to work on. i'm convinced this is an apache configuration issue, as the program has no problem reading /var/www/html [the webserver document root] and any/all files/directories under it.
here are some details :
virtual centos 7 server running apache 2.4.6.
the program runs as user apache
it can read / [root dir] and interprets it correctly [i.e. it really is / the system root, not /var/www/html]
it doesn't have access to /tmp at all, nor to /var/tmp
some external files are network mounted on /mnt. the program can access /mnt, but attempts to read /mnt/{anything} fail -- even though remote shares are mounted w/effective uid/gid as apache and all files/directories are readable by world.
selinux is currently disabled
for kicks, i tried setting Require all granted inside <Directory / > and <Directory /tmp > in httpd.conf, but that didn't change anything.
does anyone have any idea what could be causing this and how i could fix it ?
thanks.
Have you checked to see if selinux is restricting access?
You can see if Selinux is causing issues by install selinux troubleshooting
yum install -y setroubleshoot
sealert -a /var/log/audit/audit.log

pi raspbian buster apache2 www-data forbidden on different directory 2021

I have searched for recent posts on this, and older ones do not fix the issue.
I have Rasbian Buster (2021) on a pi4. Apache2.
The default /var/www/html works
trying to move it to a hdd /media/pi/Data/www/html fails
I have given it www-data user and group permissions for all folders.
I have checked that it has this in GUI and console.
Looking at the permissions on /var/www/html they are ROOT when apache2 is installed and this site works. BUT all documents say it should be www-data. Ihave not tried changing it as it will probably break it and is my reference.
I have checked that apache2 envars APACHE_RUN_USER = www-data and APACHE_RUN_GROUP=www-data
So why does it install /var/www/html as ROOT but all documents (rightly) say www-data should have permissions then it still not work?
For example I followed https://pimylifeup.com/raspberry-pi-apache/ and logged ou etc and it still fails ith Forbidden :Yu dn'thave permission to access this resource.
There seem to be varying ways to fix it, but not so only www-data has access, and I shouldn't need ROOT to have it as its very bad practice...so why does the default site have it?!
Wht is the correct fix to use adifferent directory for the website (eventualy it will be webdav but one simple step at a time!)
Thank you

Apache can't serve DocumentRoot : no execute permission error

I am trying to migrate a web application from a Slackware config of Apache to a CentOS 7 one. DocumentRoot set to /home/STORAGE and there is a simple index.html file in it for testing. Both /home/STORAGE and index.html have 777 permissions set, yet Apache reports :
access to /index.html denied ... because search permissions are missing on a component of the path.
On the other hand, phpMyAdmin works fine, configured with a separate .conf file in /etc/httpd/conf.d . I tried using their example to make a .conf file for my app, but it still reports the same error. I don't even know where to start looking here.
EDIT:
I think this has something to do with the user of Apache. It is set to a local user in httpd.conf not to root, but the only pages the server serves are those in directories owned by root.
It was not a permission error but a Selinux issue. I decided to use the default /var/www/html for the application but still, had to allow write access to some dirs. Here is what I typed:
sudo chcon -t httpd_sys_rw_content_t /some/dir/in/var/www/html -R
The first time I typed it without -R and the permissions didn't change (check with ls -Z /dir/path). Now it is fine.

Access forbidden on apache2 on ubuntu14.04

I have installed apache2 server on Ubuntu 14.04. It is working well with the files and directories which i have created here after installation, but if i copy any file or folder from anywhere else (already written) then is gives Forbidden error message.
Thanks in advance.
For a file to be accessible by apache2, it should be owned by the user which runs the apache2 server. On most systems the user is www-data or httpd or apache. To find which user is that, just look into your apache2.conf or httpd.conf. Once you know the user, make it the owner of the copied files/folders or reiterate it for the whole /var/www//html folder.
sudo chown -R www-data:www-data /var/www/html
This should do it. But, if it doesn't, verify that the user has at least read and execute permissions on the folder (write also, if you need to write some data through your script).

how to configure apache to run pages with a different group id than files

I have a vps with godaddy with the following:
centos 6
latest apache
whm/cpanel
I am running with suphp enabled.
files and folders are all 755,644
i have a program located at:
/home/programname/public_html
this program edits files located on the same server in different user accounts. in order for this to happen i have to:
chown programname:programname /home/username/public_html
this allows the files to be edited by the program running at /home/programname/public_html
when i try to view the files at
/home/username/public_html
at its domain name
username.com
I get an "The server encountered an internal error or misconfiguration and was unable to complete your request."
in order to fix this i have to
chown username:username /home/username/public_html
how do i fix this so i can view the website files without having to chown the files?
You can use ACLs:
Enable ACLs on a filesystem:
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-acls.html
Set ACLs on a filesystem:
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/acls-setting.html
There is also an apache module that I haven't had much luck with:
apache2-mpm-itk - http://www.webtatic.com/packages/httpd-itk/
It has some issues because it doesn't support prefork properly.