DEV Community

idawnwon
idawnwon

Posted on

1 2

WordPress File Permissions/Privileges Best Practices

3 very important general rules:

All files should be 664.
All folders should be 775.
wp-config.php should be 660.

A quick way to do this:

For example, I copied the whole 'themes' folder from local to server, replaced the old one on server. Then I have to carefully manipulate the chown and chmod:

# dive into 'wp-content' folder, 
# where contains 'themes' folder.
cd /A/CERTAIN/PATH/wp-content

# change privilege of 'themes'
sudo chmod 775 themes 

# ATTENTION! For I am currently using 
# 'Bitnami WordPress Production-Ready 
# Stack Deployment On AWS' solution, 
# I confirmed before replacing 'themes', 
# the original group is 'root' and 
# owner is 'daemon'. So please confirm 
# yours before do this step.
#
# This step is to change 'themes' OWNERGROUP 
# to 'root' and OWNER to 'daemon'.
sudo chown -R root:daemon themes 

# dive into 'themes'
cd themes

# change all files to 664
sudo find . -type f -exec chmod 664 {} + 

# change all folders to 775
sudo find . -type d -exec chmod 775 {} + 
Enter fullscreen mode Exit fullscreen mode

Inspired by Benjamin's detailed article @ smashingmagazine.com

Hope this helps!
So proud to be a coder!

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
Sloan, the sloth mascot
Comment deleted

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs