Making files writeable for the WordPress theme editor

Changing something small, on the fly, is possible in WordPress by navigating to Appearance -> Editor. It’s a great tool if you need a web guru on your server but you don’t want to give him access to your backend. But them he calls you and explains that he is getting the following error when trying to edit your theme files using the WordPress editor

"You need to make this file writable before you can save your changes. See the Codex for more information."

Ok, sure, I’ll check the codex. But it still doesn’t work, even with permissions of 777 (or -rwxrwxrwx)!

To ensure you can write to files, make sure of the following three items. Note: this guide applies to a Ubuntu/Debian style system but you should be able to addapt where necessary for other flavours of Linux/Unix – or just ask in the comments section and I’ll see what I can find:

1. Ensure your folder permissions for the applicable theme are correct (should be 755 / drwxr-xr-x):

## Navigate to [server]/[blogname]/wp-content/themes/[themename] on your server, e.g. ##
 
admin@techedemic:~$ cd /var/www/techedemic/wp-content/themes
admin@techedemic:/var/www/techedemic/wp-content/themes$ ls -alh
total 24K
drwxr-xr-x 5 www-data  www-data 4.0K 2013-09-23 15:44 .
drwxr-xr-x 5 www-data  www-data 4.0K 2013-09-23 15:46 ..
-rw-r--r-- 1 www-data  www-data   30 2013-09-23 15:05 index.php
drwxr-xr-x 5 www-data  www-data 4.0K 2013-09-23 18:21 techedemic
drwxr-xr-x 7 www-data  www-data 4.0K 2013-09-23 15:06 twentyeleven
drwxr-xr-x 4 www-data  www-data 4.0K 2013-09-23 15:06 twentyten

2. Ensure your file permissions for the applicable theme are correct (should be 644 / drwxr-xr-x)

admin@techedemic:/var/www/techedemic/wp-content/themes/techedemic$ ls -alh
total 236K
drwxr-xr-x  5 www-data www-data 4,0K May 22 08:40 .
drwxr-xr-x 18 www-data www-data 4,0K Oct  3 11:17 ..
-rw-r--r--  1 www-data www-data  812 Oct  1  2012 404.php
-rw-r--r--  1 www-data www-data 1,7K Oct  1  2012 changelog.txt
-rw-r--r--  1 www-data www-data 1,8K Oct  1  2012 comments.php
-rw-r--r--  1 www-data www-data 1,8K Oct  1  2012 content-aside.php
-rw-r--r--  1 www-data www-data 2,8K Oct  1  2012 content-audio.php
-rw-r--r--  1 www-data www-data 2,7K Oct  1  2012 content-chat.php
...
...snipped...
...
-rw-r--r--  1 www-data www-data  353 Oct  1  2012 page.php
-rw-r--r--  1 www-data www-data  882 Oct  1  2012 sidebar.php
-rw-r--r--  1 www-data www-data  357 Oct  1  2012 single.php
-rw-r--r--  1 www-data www-data  22K Oct  1  2012 style.css

3. Ensure the owner of the files is set as www-data:www-data . I found that if this step is not done, even permissions of 777 won’t work.

Your web server might run as a different user. Change accordingly. If you don’t know what I mean, perhaps it’s time to ask someone to assist because you might break something here.

Add a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Comments

  1. I see you share interesting content here, you can earn some additional cash, your website
    has big potential, for the monetizing method, just
    search in google – K2 advices how to monetize a website

    Reply
  2. Hi thanks for this useful post. I’m still having a bit of an issue trying to make that message go away.

    I know that I can probably resolve this by going the FTP route, but I’m trying to use the command line (WP-CLI) as much as possible..

    I just began learning and I don’t know how to get the screens you posted on the Mac Terminal. Do you have any additional advice?

    Reply
    1. Hi John,

      The outputs I have in the post are from the command line . You can either connect to your server via SSH or if you have console access (screen/mouse/keyboard) to your server you can just open the terminal.

      On an Ubuntu/Debian based server, the files are normally located in either /var/www/[website] or /var/www/html/[website]

      So, from a Mac terminal, you would likely connect via SSH as follows (I’m guessing, unfortunately don’t own a Mac or have access to one)


      # First, connect to server
      ssh user@server
      # Enter your password
      Password:

      #navigate to directory where files are located.
      cd /path/to/your/wordpress/site

      #execute permission changes

      Remember, the user you log in with will need appropriate permissions on the folders/files.

      Reply