permission in var/www on ubuntu - apache

I was able to access and view the files when i first set it. i then realize that my css sheet was not running so i check the source code in Firefox and realize that i didn't have permission to view this file. so i decided to run a permission on the entire www folder.
Now im getting a 403 error. i tried changing back the permission but still having the same problem. i tried
find /var/www/ -type d -exec chmod 755 {} \;
find /var/www/ -type f -exec chmod 644 {} \;
these didn't work, please help

sudo chmod 0777 -R /var/www
-R is recursive, I assume that your web files are located in /var/www.

Related

Copy folder + subfolder + inner files access permissions and ownerships from one folder to an other (recursively)

How do I copy all the folder, subfolders and files permissions (recursively) from /www_03062018 to my new /www ?
I came across this post: https://superuser.com/questions/625673/clone-permissions-for-all-files-in-a-folder
chmod --reference=RFile file
Which didn't help much, it did apply a change for the main folder /www but didn't apply on its subfolders and files.
i have tried:
chmod -R --reference=/www_03062018 /www
and it didn't work.
My situation:
I have 2 folders on my Ubuntu machine: /www and /www_03062018.
/www is a "git clone" from the production machine.
/www_03062018 is my old directory that i used to work on and upload files via FTP.
I started to use GIT and when I clone a directory - all its folder ownerships and file accesses settings doesn't get cloned too.
cd to the new directory which you want to give new permissions - in my case:
cd /www
For CHMOD this worked:
find . -path ./.git -prune -or -exec chmod --reference '/www_03062018/{}' '{}' ';'
And for CHOWN this worked:
find . -path ./.git -prune -or -exec chown --reference '/www_03062018/{}' '{}' ';'
Hope this helps others :) !

Magento httpd permissions issues

I am trying to install magento2 on a CentOS server. I am continuously getting permissions issue, the magento diretory is owned by apache and I set permissions to 777 (i know it is bad but just to test) but I still get permissions denied on file write. the path to magento dir is /var/www/html. I set permissions to /var/www/ and all sub-folders to 777 and file owner to apache still same.
also
egrep -i '^user|^group' /etc/httpd/conf/httpd.conf (returns)
User apache
Group apache
any suggestions or ideas, please?
Kind Regards
Sajid
Try following steps
sudo /usr/sbin/groupadd wwwrun
sudo usermod -g wwwrun test
cd /var/www/html/magento2 && sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && sudo chown -R apache:apache . && sudo chmod u+x bin/magento
where test is the current logged-in user and then restart the http server.

AH00035: access to / denied (filesystem path '/Users/xxx/Documents/workspace') because search permissions are missing on a component of the path

Trying to set localhost on my mac and made following changes in /etc/apache2/httpd.conf
DocumentRoot "/Users/xxx/Documents/workspace/firstRepo/htdocs"
<Directory "/Users/xxx/Documents/workspace/firstRepo/htdocs">
I know it's something to do with the dir permission, so I followed suggestions online and ran the following commands:
find /Users/xxx/Documents/workspace -type d -exec chmod 755 {} \;
find /Users/xxx/Documents/workspace -type f -exec chmod 644 {} \;
No luck here. Can someone help me with this? Thanks.
Unix permissions are not just "permissions in destination", you need "search" permissions for the whole path until the last directory as the message from Apache says
Search permissions means, in a simple explanation, "x" is at least missing in directories so the unpriviledged user apache is using can go the whole path until reaching "/Users/xxx/Documents/workspace/firstRepo/htdocs".
You can try this command to make sure you have them:
namei -mol /Users/xxx/Documents/workspace/firstRepo/htdocs
Only other case of not being able to access where permissions are correct is if SELinux is controlling access to those directories.
The Apache wiki has a document about this since many people get confused about how permissions work under Unix. Permissions
this error can be resolved more specific way eg. :
semanage fcontext -a -t httpd_sys_content_t "/var/www/htmlxx(/.*)?"
restorecon -F -R -v /var/www/htmlxx
you may take a look at oracle base article once

Changing the permission so the directory is world writable on CentOS 7

I've installed Xenforo on my digitalocean VPS running CentOS 7, I get this error as soon as I open the web page. `The following errors occurred while verifying that your server can run XenForo:
The directory /var/www/html/data must be writable. Please change the permissions on this directory to be world writable (chmod 0777). If the directory does not exist, please create it.
The directory /var/www/html/internal_data must be writable. Please change the permissions on this directory to be world writable (chmod 0777). If the directory does not exist, please create it.
Please correct these errors and try again.
How would I change the permission for the directory so it can be world writable?
Basically data and internal_data are directories in which the user running Xenforo should be able to write, because they will contain attachments, avatar, and other files.
Usually the user running PHP on Apache or Nginx is www-data in the group www-data (user and group have the same name), so all you have to do is letting this user to write on data and internal_data:
chown -R www-data.www-data /var/www/html/data /var/www/html/internal_data
If you want to follow literally the advice given in the error message you can do this instead:
chmod -R 0777 /var/www/html/data /var/www/html/internal_data
But as others commented, this approach is more insecure, because it will permit any user in the system to write in data and internal_data directories.
This is what is recommended for Xenforo 2 on nginx on CentOS per CentMinMod & Xenforo documentation. It is required to do it like this or Xenforo2 will not work. I have used this on multiple sites without issue. Make a backup first to be safe.
find /home/nginx/domains/domain.com/public/ -type f -print0 | xargs -0 chmod 0644;
find /home/nginx/domains/domain.com/public/ -type d -print0 | xargs -0 chmod 0755;
find /home/nginx/domains/domain.com/public/internal_data/ -type f -print0 | xargs -0 chmod 0777;
find /home/nginx/domains/domain.com/public/data/ -type f -print0 | xargs -0 chmod 0777;
find /home/nginx/domains/domain.com/public/internal_data/ -type d -print0 | xargs -0 chmod 0777;
find /home/nginx/domains/domain.com/public/data/ -type d -print0 | xargs -0 chmod 0777;
chmod 0750 /home/nginx/domains/domain.com/public;

Apache File permissions issue in Ubuntu

I'm trying to use Apache to access a file on my Documents folder.
I tried the following:
sudo chown -R www-data:www-data /home/$USER/public_html
sudo adduser $USER www-data
sudo chmod -R 775 /home/$USER/public_html
As suggested by this post:
https://askubuntu.com/questions/26848/permissions-issue-how-can-apache-access-files-in-my-home-directory
Although this works, now I cannot edit or the files directly as the user (without using sudo), despite being a member of the www-data group. The only solution that seemed to work is using chmod -R 777 (which I rather not do).
Turns out all I had to do is restart the OS and it was sorted!