-
-
Save Adirael/3383404 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# This script configures WordPress file permissions based on recommendations | |
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions | |
# | |
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org> | |
# | |
WP_OWNER=www-data # <-- wordpress owner | |
WP_GROUP=www-data # <-- wordpress group | |
WP_ROOT=$1 # <-- wordpress root directory | |
WS_GROUP=www-data # <-- webserver group | |
# reset to safe defaults | |
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \; | |
find ${WP_ROOT} -type d -exec chmod 755 {} \; | |
find ${WP_ROOT} -type f -exec chmod 644 {} \; | |
# allow wordpress to manage wp-config.php (but prevent world access) | |
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php | |
chmod 660 ${WP_ROOT}/wp-config.php | |
# allow wordpress to manage wp-content | |
find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \; | |
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \; | |
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \; |
Anyone guide me where I paste that query to solve my problem.......?Or tell me how I put my .sh file to fix that bug.Thanks.Waiting for reply.
@M-Faizan480 it is a script not a web query. You need shell / ssh access to your server. Login to the Linux terminal of your host then execute the file.
Many thanks for this. It works like a charm.
It's 2020. Still works like a charm! Thank you 👍
Isn't putting everything to www-data going to be insecure?
www-data is for developpement.
root or other is for production
If you use root, a file can't be modified by apache
For exemple, if you use a CMS ( WP / Joomla ... ) and if all your file is for root, a CMS update can't change the existing files.
Then, your CMS is a little more protected. Only root can change the good right. Use www-data:www-data for apply a CMS update and protect all file with root:root or root:www-data ( need read more information for that. )
still I am getting the errors although I did what you have suggested . I am using architect theme
this is the message :
Fatal error: Uncaught Error: Call to undefined function ctype_xdigit()
in /hermes/bosnacweb05/bosnacweb05ab/b1567/ipg.zohair9856655/mysite.com/wordpress/wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-colors.php on line 205
Call stack:
Redux_Colors::sanitize_hex()
wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-colors.php:276
Redux_Colors::sanitize_color()
wp-content/plugins/redux-framework/redux-core/inc/validation/color/class-redux-validation-color.php:42
Redux_Validation_Color::validate()
wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-validate.php:39
Redux_Validate::__construct()
wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-validation.php:197
Redux_Validation::validate()
wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-options-constructor.php:907
Redux_Options_Constructor::validate_options()
wp-includes/class-wp-hook.php:289
WP_Hook::apply_filters()
wp-includes/plugin.php:206
apply_filters()
wp-includes/formatting.php:4899
sanitize_option()
wp-includes/option.php:368
update_option()
wp-admin/options.php:314
thanks
Hi all,
I am a complete nitwit here. Can someone explain to me step by step from the beginning what I have to do correct the error with cropping photo's? Thanks in advance.
I'm not really sure if you are at the right place to find a solution for correcting the error with cropping photos!!
This is a shell file to fix the permissions of files used in Wordpress.
like magic
If you are having "No such file or directory" problems and you use windows to upload the file a quick fix is changing the format to unix again:
#vim fix_permision.sh
:set fileformat=unix
:wq
#sh fix_permision.sh
Thank you!! This worked, while everything else on internet failed.
Thanks, it works very well
I'm using centos/cpanel/litespeed and I have the following error:
chown: invalid user: www-data:www-data
chgrp: invalid group: www-data
how should I fix it ?@msesxi I use VPS with Openlitespeed 1.6.8 try change group with nogroup and user with nobody should be like this : WP_OWNER=nobody # <-- wordpress owner (if you use shared host, but if use VPS like me try your user and group instead) WP_GROUP=nogroup # <-- wordpress group WP_ROOT=$1 # <-- wordpress root directory WS_GROUP=nogroup # <-- webserver group
Yeeaaa, something like this... Not sure if just, they didn't mention cpanel in the mix... or cloudlinux specific ontop centos...
From my current research nobody is right, but not the nogroup.
Just stumbled back upon this piece out of a general 403 error troubleshoot KB:
Incorrect File Ownership After Migration[¶](https://docs.litespeedtech.com/lsws/cp/cpanel/403-error/#incorrect-file-ownership-after-
migration)
When migrating or uploading files to a cPanel account, some image files might incorrectly be assigned to nobody:nobody, when they should be user:user./home/jsmith/public_html>ls -ald images/detailed/130/Untitled-1-Recovered_urba-uz.jpg
-rw-rw-rw- 1 nobody nobody 103609 Apr 12 11:21 images/detailed/130/Untitled-1-Recovered_urba-uz.jpg
/home/jsmith/public_html>ls -ald images/detailed/130
drwxrwxrwx 2 nobody nobody 36864 Apr 14 15:12 images/detailed/130
/home/jsmith/public_html>ls -ald images/detailed
drwxrwxrwx 51 jsmith jsmith 4096 Apr 11 13:16 images/detailed
/home/jsmith/public_html>ls -ald images
drwxrwxrwx 48 jsmith jsmith 4096 Mar 31 16:30 images
The Force Strict Ownership setting in LSWS Admin specifies whether to enforce strict file ownership checking. If it is enabled, the web server will check if the owner of the file being served is the same as the owner of the virtual host. If it is different, a 403 Access Denied error will be returned.To fix the problem, either change all files user:group to user:user ( in the above example, that would be jsmith:jsmith), or disable Force Strict Ownership in LSWS Admin.
leaving these tabs open now, think I'm going to make a master doc on this craziness lol. Likely become very popular since it's been a nightmare getting all the right little config info on this lsws cpanel cl setup lol. Installed CL manually on linode with custom distribution installation and custom recommended for performance cpanel partitions. That was a 3 - 5 day battle lol. Documented the heck out of that one... Literally could not find one person on the net with a guide on custom install Cloudlinux 8, for cPanel specific partition setup. Definitely gave me some food feature requests for linode tho lolol.
you did it nicely when back then there was not chatgpt! Cheers!
even after a decade this is my go to fix.
Thank you!