WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Changing File Permissions"

m (Reverted edits by Glossyboy (Talk); changed back to last version by Morgansutherland)
m (Using the Command Line)
Line 51: Line 51:
   
 
# Go to your WordPress main directory, with a command like <code>cd wordpress/</code>
 
# Go to your WordPress main directory, with a command like <code>cd wordpress/</code>
# Enter <code>chmod -R 777 wp-content</code>
+
# Enter <code>chmod -R 766 wp-content</code>
   
What does this mean? <code>chmod</code> is a unix command that means "<strong>ch</strong>ange <strong>mod</strong>e" on a file. The <code>-R</code> flag means to apply the change to every file and directory inside of <code>wp-content</code>. 777 is the mode we are changing the directory to, it means that the directory is readable and writable by WordPress. Finally, we have the name of the directory we are going to modify, <code>wp-content</code>.
+
What does this mean? <code>chmod</code> is a unix command that means "<strong>ch</strong>ange <strong>mod</strong>e" on a file. The <code>-R</code> flag means to apply the change to every file and directory inside of <code>wp-content</code>. 766 is the mode we are changing the directory to, it means that the directory is readable and writable by WordPress and any and all other users on your system. Finally, we have the name of the directory we are going to modify, <code>wp-content</code>. If 766 doesn't work, you can try 777, which makes all files and folders readable, writable, and executable by all users, groups, and processes.
   
   
Line 60: Line 60:
 
# Go to the main directory of WordPress
 
# Go to the main directory of WordPress
 
# Enter <code>chmod 666 .htaccess</code>
 
# Enter <code>chmod 666 .htaccess</code>
 
 
 
   
 
== See also ==
 
== See also ==

Revision as of 08:36, 8 December 2008

On computer filesystems, different files and directories have permissions that specify who and what can edit and read them. This is important because WordPress may need access to write to files in your wp-content directory to enable certain functions.

Here is one possible permission scheme.

All files should be owned by your user account, and should be writable by you. Any file that needs write access from WordPress should be group-owned by the user account used by the webserver.

  • / - The root Wordpress directory: all files should be writable only by your user account
    • EXCEPT .htaccess if you want WordPress to automatically generate rewrite rules for you
  • /wp-admin/ - the WordPress administration area: all files should be writable only by your user account.
  • /wp-includes/ - the bulk of WordPress application logic: all files should be writable only by your user account.
  • /wp-images/ - image files used by WordPress: all files should be writable only by your user account.
  • /wp-content/ - variable user-supplied content
    • /wp-content/themes/ - theme files. If you want to use the built-in theme editor, all files need to be group writable. If you do not want to use the built-in theme editor, all files can be writable only by your user account
    • /wp-content/plugins/ - plugin files: all files should be writable only by your user account.
    • other directories under /wp-content/ should be documented by whatever plugin / theme requires them. Permissions will vary.
    • The WordPress Database Backup Plugin requires the /wp-content/ folder be made writeable. In some cases, this may require assigning 755 permissions or higher (e.g. 777 on some hosts).

Also see the discussion in this Forum thread.

Using an FTP Client

FTP programs ("clients") allow you to set permissions for files and directories on your remote host. This function is often called chmod or set permissions in the program menu.

In a WordPress install, two files that you will probably want to alter are the index page, and the css which controls the layout. Here's how you change index.php - the process is the same for any file. In the screenshot below, look at the last column - that shows the permissions. It looks a bit confusing, but for now just note the sequence of letters.

Initial permissions

Right-click 'index.php' and select 'File Permissions'
A popup screen will appear.

Altering file permissions

Don't worry about the check boxes. Just delete the 'Numeric value:' and enter the number you need - in this case it's 666. Then click OK.

Permissions have been altered

You can now see that the file permissions have been changed.

Unhide the hidden files

By default, most FTP Clients, including FileZilla, keep hidden files, those files beginning with a period (.), from being displayed. But, at some point, you may need to see your hidden files so that you can change the permissions on that file. For example, you may need to make your .htaccess file, the file that controls permalinks, writeable.

To display hidden files in FileZilla, in it is necessary to select 'View' from the top menu, then select 'Show hidden files'. The screen display of files will refresh and any previously hidden file should come into view.

To get FileZilla to always show hidden files - under Edit, Settings, Remote File List, check the Always show hidden files box.

Using the Command Line

If you have shell/SSH access to your hosting account, you can use chmod to change file permissions. Before you start using chmod it would be recommended to read some tutorial like this and also the manual page to make sure you understand better what you can make with it.

You can make all the files in your wp-content directory writable in two steps:

  1. Go to your WordPress main directory, with a command like cd wordpress/
  2. Enter chmod -R 766 wp-content

What does this mean? chmod is a unix command that means "change mode" on a file. The -R flag means to apply the change to every file and directory inside of wp-content. 766 is the mode we are changing the directory to, it means that the directory is readable and writable by WordPress and any and all other users on your system. Finally, we have the name of the directory we are going to modify, wp-content. If 766 doesn't work, you can try 777, which makes all files and folders readable, writable, and executable by all users, groups, and processes.


If you use Permalinks you should also change permissions of .htaccess to make sure that WordPress can update it when you change settings or add some new Page (which requires update of the file to work when Permalinks are enabled).

  1. Go to the main directory of WordPress
  2. Enter chmod 666 .htaccess

See also

htaccess for subdirectories