unable to access htacces in subdirectory/subdomain

nurvianto

New member
Joined
Jan 15, 2020
Messages
3
Hello,

This is the first time using DA.
After migration from cpanel, I found that htaccess is not working in subdirectory.
Here is the example error_log

[Wed Jan 15 05:35:45.926716 2020] [core:crit] [pid 2348901:tid 139619538147072] (13)Permission denied: [client 95.108.213.29:61529] AH00529: /home/xxx/domains/xxx.com/public_html/blog/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/xxx/domains/xxx.com/public_html/blog/' is executable

I have tried ./set_permissions.sh, but It is still not working.
I need help how to fix this issue globally.
Thanks

Regards
Nurvianto
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,384
Location
Maastricht
Just to be sure, you used the ./set_permissions.sh the correct way? Should be like this:
Code:
/usr/local/directadmin/scripts/set_permissions.sh user_homes
Are you using Apache or Nginx? And what php mode are you running? Mod+php, mod_ruid2, php-fpm?

You could also try to run:
Code:
cd /usr/local/directadmin/custombuild/
./build update
./build rewrite_confs
Check folder permissions anyway and also folder owner.
 

nurvianto

New member
Joined
Jan 15, 2020
Messages
3
Code:
/usr/local/directadmin/scripts/set_permissions.sh user_homes
not working

Code:
cd /usr/local/directadmin/custombuild/
./build update
./build rewrite_confs
not working

You can check folder's permission too.

Good luck
Check folder permissions anyway and also folder owner.
folder/subdomain/ permission is 750
after I change to 755 , the site is working again

but there are many subdomain / folder in server,
so I need bulk solution
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,384
Location
Maastricht
I suggest sending in a ticket, because the ./set_permissions should fix this already.

However, as for a bulk solution with console output:
Code:
find /home/*/domains/*/public_html -type d -print0 | xargs -0 chmod 755
find /home/*/domains/*/public_html -type f -print0 | xargs -0 chmod 644
which will change directory's to 755 and files to 644 as it should be.

You can change /home/*/domains to /home/username/domains if it's only for 1 user, or adjust the line to your needs in other places.

Or use a shorter version:
Code:
find /home/*/domains/*/public_html -type d -exec chmod 755 {} \;
find /home/*/domains/*/public_html -type f -exec chmod 644 {} \;
Again, change /home to your needs.

For both ofcourse, no warranty, use at your own risk.
 
Last edited:

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,384
Location
Maastricht
With the suggested commands you open users dirs for reading by other users on the same server. It's insecure.
That would indeed be correct Alex for the shorter command. But as specifically stated it was just an example which should be fitted to the needs.

However, since there are always people not reading correctly and just copying and pasting, I editted my post and completed the lines to a directly usable example.
 

duntuk

Verified User
Joined
Jan 23, 2007
Messages
48
The reason likely why it works with 755 and not 750 (or 644 vs 640) is because you have permissions set as username:username

For php-fpm , user:group permissions for, example, .htaccess would need to be username:apache in order to use 640 -- if 644, then you can use username:username, but it's readable by everyone.

Can someone provide the best-practices for permissions here on php-fpm, because I'm not entirely sure myself--since we did just switch to php-fpm recently.
 
Last edited:

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,094
Location
GMT +7.00
For php-fpm , user:group permissions for, example, .htaccess would need to be username:apache in order to use 640 -- if 644, then you can use username:username, but it's readable by everyone.
That's wrong for DirectAdmin servers. All user files on DirectAdmin servers under document root should be owned and group-owned by username.
 
Top