Apache Access denied after changing the web root permissions - apache

I recently changed the document root permissions to everyone using this command:
sudo chmod -R 753 /var/www
But not when I access the website, I get the error.
You don't have permission to access /index.html on this server.
I tried modifying the http.conf to allow access but nothing happened. Basically, how do i undo this command?

You need to allow access to apache user and group for your /var/www directory to work your sites. You need to assign 755 permission to your /var/www directory

Related

Why did "chown" and "chgrp" changed permissions of a directory? It is not a "chmod"!

Everything was good on my website. Then I ran this:
root#[domain] [/home/[username]/public_html/[foldername]]# chown jaimemontoya -R webroot/
root#[domain] [/home/[username]/public_html/[foldername]]# chgrp jaimemontoya -R webroot/
What I was trying to do with the above was to change ownership from root to jaimemontoya for the webroot directory, and do it recursively. The result was that PERMISSIONS of webroot were changed from drwxr-xr-x to drwxr-x---. As a result, my entire website was down with the following error when visiting the home page:
Forbidden
You don't have permission to access /[foldername]/webroot/[location-name] on this
server. Server unable to read htaccess file, denying access to be safe
Additionally, a 403 Forbidden error was encountered while trying to
use an ErrorDocument to handle the request.
I fixed it by modifying permissions for the webroot directory, changing it from drwxr-x--- to drwxr-xr-x, since originally I was using drwxr-xr-x.
Bottom line: Why did using chown jaimemontoya -R webroot/ and chgrp jaimemontoya -R webroot/ changed PERMISSIONS of the webroot directory? It should have only changed OWNERSHIP, NOT PERMISSIONS. It was my understanding that if you needed to change PERMISSIONS you would need to use chmod, and I never used that. Thank you.
As I mentioned it in the question, I fixed it by modifying permissions of the webroot directory, changing it from drwxr-x--- to drwxr-xr-x. Of course I asked this question because I am trying to understand WHY the problem happened. Nonetheless, I know the solution and that is the most important thing.

Unable to get access to specific directory to run a site on ec2

Still fairly new to ec2, I made a new directory as /home/user/www. Opened ftp service that allows git commits to be pushed to the server. This works fine as I can see the files come up. The problem being when I run my site, the Apache test page pops up and when I try opening a page in /home/user/www directory, it says Forbidden, you don't have permission to access / on this server.
I have successfully changed the DocumentRoot
DocumentRoot "/home/user/www"
AllowOverride None
# Allow open access:
Require all granted
and Directory in httpd.config to /home/user/www, all but to no result.
Any help is appreciated. Permissions are 777 for test basis but still no success. User is the owner of all the files in www
Solved my own question. Permissions need to be set on the third directory i.e., www. Therefore, I did chmod 755 ~/www.
Worked like a charm

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).

HTTP Server Error 403. Forbidden

I am getting the following error:
Forbidden: You don't have permission to access [directory] on this server.
I need direct access to this directory and sub folders on that directory so that my Android Application can communicate with it.
I tried putting folders on a Hosting Server and everything works fine.
But, I am doing an academic project and I need to store these folders and scripts on a University Web Server which can talk to localhost locally.
1.
If you have the possiblity and your server is a linux server, you can change the permissions with something like
sudo chmod -R 777 /var/www/folder
Or completely change the owner with
sudo chown -R user /var/www/folder
2.
Look into the apache configuration files and also the .htaccess, if the directory is blocked by
Deny from all
Or simply not allowed. You could allow the directory by creating a .htaccess file and enter
<Directory yourdirectory>
Order allow,deny
Allow from all
</Directory>