Jason G. Designs

WordPress Themes, Print-On-Demand Resources and more…

Ubuntu Linux, Permissions and a Local WordPress Install

by Jason Gonzalez

Posted in Categories: Articles

14
Jan
2012

Flames and codeUpon installing LAMP and WordPress 3.3 on my local computer, I ran into a couple issues when trying to put my own previously created themes into the wp-content/themes directory. Mainly, it was the “Connection Information” screen that may pop up when installing a theme, not being able to access the /themes directory and the Manage Themes screen not recognizing themes once I had access. This article describes how I researched then remedied those. I primarily followed the tutorials How To Install LAMP (Linux, Apache, MySQL, PHP) On Ubuntu 11.04/11.10 and How To Install The Latest WordPress Version On Ubuntu 11.10/11.04.

Getting Rid of the “Connection Information” screen

After locally installing WordPress in Ubuntu Linux 11.10, I was asked to provide an FTP hostname, username and password when trying to download a theme. The issue was that I was not using ftp on a local install, therefore I probably did not know what to input in those fields. I tried every password and username combination I could think of: my WordPress admin username/password, my Ubuntu account’s username/password. None of these worked. This is because Apache does not have permissions to write to the wp-content directory. Luckily, I applied the information found in the article Why WordPress Asks for Connection Info.

  1. First, we need to see what user Apache is running under. Type the following into a New file in any text editor. Save As whoami.php in the /var/www directory (or wherever you set Apache to serve files from):
    <?php echo(exec("whoami")); ?>
  2. Open this file in a browser (for instance, localhost/whoami.php). It should reveal who the user is
  3. Next, we change the owner of the wordpress directory to the user that is shown with whoami.php. In my installation that user is www-data. Open the Terminal application and type:
    sudo chown -R [user] wordpress

    Type in your super user password. In this case, replace [user] with www-data. The -R option is important, as it changes the owner for every file within the wordpress directory.

Now, you should be able to download themes and plugins and bypass the Connection Information screen. Many thanks go to Chris Abernethy for this solution.

Making sure WordPress’s Manage Themes Screen Can See Files Dropped into the /themes/ directory

This part took literally days and hours of setting and resetting permissions to figure out what works best. This may not be optimal for everyone, but this worked for me as a newbie to Linux.

  1. I Set permissions on the /var/www directory to 777. After reading many forums, someone suggested to set the permissions this way. This is normally very unsafe, but since this is a local install that only the owner can access, it should be okay. It is advised to NEVER set such loose permissions on directories in an online server
    sudo chmod -c -R 777 /var/www

    If anyone has a less permissive way to do this, please let me know in a comment below.

  2. By this time, I had some previously created themes to drop into the /themes/ directory. To test this, you can try manually downloading a theme, unzipping it and placing the theme’s inner folder in the /themes/ directory.
  3. Next, we need to change the group of the /themes/ directory so our current user can add and remove files and directories:
    sudo chgrp -c -R [ubuntu username] /var/www/wordpress/wp-content/themes/

    The Ubuntu username is a user account name. I would replace that with jason in my account

  4. When I dragged the theme to the /themes/ directory, the owner was set to jason (my Ubuntu username). But, in order for the Manage Themes admin screen to recognize the theme, the owner of the directory needs to be set to www-data (in my case)
    sudo chown -c -R www-data /var/www/wordpress/wp-content/themes/[name-of-theme-directory]
  5. Changing the owner on this directory recursively gets rid of the original chmod settings, so we must restore the 777 setting to the theme’s directory:
    sudo chmod -c -R 777 /var/www/wordpress/wp-content/themes/[name-of-theme-directory]

You can test if this works by opening up one of the theme’s files in a text editor and making a small change (an html comment or so); if you are able to save and see your changes in a browser, then it is successful.

You may ask, “Why not just stop at getting rid of the Connection Information screen and just upload a zip file for a theme?” Making sure the /themes/ directory is writable and visible to the Manage Themes screen will help those who need to develop a WordPress theme locally from scratch and preview as they are creating it.

I don’t consider myself an expert in Linux or WordPress. I literally learned this over two days of intensive Googling. But when I got it, I wanted to share my experiences immediately, as this may save people from a lot of frustration. Thank you for reading.

Tags for this post: , , , , , ,

17 Comments

  1. Neat blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple adjustements would really make
    my blog jump out. Please let me know where you got your design. Many thanks

  2. Thanks for this tutorial 100% work for me :)

  3. Bruce says:

    Wow, marvelous weblog structure! How lengthy have you been blogging
    for? you make blogging glance easy. The entire look of your website is magnificent, as
    neatly as the content material!

  4. Jordan Jelinek says:

    Yeah, no kidding.

  5. Milton says:

    You save my day!

  6. Newwbea says:

    it shows me that in the terminal
    chown: cannot access `wordpress': No such file or directory

    1. Jason Gonzalez says:

      Hello Newwbea. I don’t know if you’ve already resolved this issue, but was WordPress installed in your /var/www directory or somewhere else?

  7. Uytko says:

    Hi,
    This way worked for me

    cd /var/www/wordpress/wp-content/themes
    su www-data -c ‘wget http://wordpress.org/extend/themes/download/eclipse.2.0.1.zip‘; su www-data -c ‘unzip eclipse.2.0.1.zip'; rm eclipse.2.0.1.zip
    ls -l

    regards

  8. I did what you told, but nothing worked. Than I realized what the problem was.

    I installed wordpress through the terminal, so I had a symbolic link in var/www, while the archives were at usr/share (I’m using ubuntu 12.10). I tryed to do the same thing with usr/share/wordpress, but nothing worked.

    The solution: manually create a new wordpress file. It was actually easier than the method you described. I just executed a sudo chown www-data with a couple of files and then it was set.

  9. tay says:

    thanks
    you have been very helpful
    everything works fine now

  10. tay says:

    Using 12.04. Had a problem when using the command “grp”

    No command ‘grp’ found, did you mean:
    Command ‘igrp’ from package ‘irpas’ (multiverse)command not found and then give a whole array of options
    Command ‘gp’ from package ‘pari-gp’ (universe)
    Command ‘grep’ from package ‘grep’ (main)
    Command ‘grpn’ from package ‘grpn’ (universe)
    Command ‘grap’ from package ‘grap’ (universe)
    Command ‘gri’ from package ‘gri’ (universe)
    Command ‘arp’ from package ‘net-tools’ (main)
    Command ‘gip’ from package ‘gip’ (universe)
    Command ‘gpp’ from package ‘gpp’ (universe)
    Command ‘gpr’ from package ‘gpr’ (universe)
    Command ‘gap’ from package ‘gap-core’ (universe)
    Command ‘gyp’ from package ‘gyp’ (universe)
    Command ‘gcp’ from package ‘gcp’ (universe)
    Command ‘grc’ from package ‘grc’ (universe)
    Could you tell me which command I should use.
    Thanks

    Command ‘grn’ from package ‘groff’ (main)

    1. Jason Gonzalez says:

      Hello tay. The command to change the group for directories is chgrp.

  11. dt says:

    works like a dream. thanks a million
    had a slight problem, just a matter of the full directory of wordpress is required in the command
    sudo chown -R [user] wordpress

  12. Jason Gonzalez says:

    You’re welcomed. I am also thankful for the resources I found with Google for helping me write this article as well.

  13. scurveedog says:

    Jason G you are AWESOME!!!

    I too was in google and after 100’s of websites yours was the first and only one that solved this issue for me…thank you for the complete, concise instructions and sharing your knowledge

  14. TRX says:

    My wordpress blog worked after modify according your suggestion.

    Thanks

  15. datboip says:

    holy effin shtufff…. I was stuck for a week ftping this and that,,, This was all i needed! Thanks!!!

Trackbacks and Pingbacks

Trackback URL for this post: http://www.jasong-designs.com/2012/01/14/ubuntu-linux-permissions-and-a-local-wordpress-install/trackback/

  1. […] Policy « How to Bring Your WordPress Theme up to Current Standards Ubuntu Linux, Permissions and a Local WordPress Install […]

  2. […] you are developing this theme on Linux, please see the blog post Ubuntu Linux, Permissions and a Local WordPress Install before getting […]

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>