freecnpro
By:
freecnpro

How to update WordPress?

October 25, 2013 8.9k views
I isntalled WordPress in my VPS, now WordPress released a new version, I want to update it, how I should to do? When I click the WordPress update url, it need enter FTP username and password, but my VPS does not seem to install FTP.
14 Answers
If you're using Ubuntu, the relevant command is sudo chown -R www-data:www-data /path/to/WordPress_directory
@Andrew SB, thanks for a great response, this process scares the crap out of me and I don't want to mess it up.

In the tutorial at,
https://www.digitalocean.com/community/articles/how-to-install-wordpress-on-ubuntu-12-04

it instructs me to do this,

"We are almost done uploading Wordpress to the virtual private server. The final move that remains is to transfer the unzipped WordPress files to the website's root directory.

sudo rsync -avP ~/wordpress/ /var/www/

Finally we need to set the permissions on the installation. First, switch in to the web directory:

cd /var/www/ "

...Have I missed something? Did it not actually move the WP install to that directory in the install process like I thought?

Looking through all the files in SFTP I see, root/wordpress/ is that what ~/wordpress/ is referring to?

I just want to be sure I am changing permissions to the right directory. I found someone else with the same issue here,
https://www.digitalocean.com/community/questions/how-do-i-enable-wordpress-to-update-itself-through-its-back-end
and in this someone suggested to use,

sudo chown -R www-data:www-data /var/www

This seems like the one I should use, is that correct?

I also pasted my output from,
ls -la /var/www
and got this,

http://pastie.org/9144678#1
by Etel Sverdlov
Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality. This tutorial shows how to install Wordpress on a server with LAMP. It is written for Ubuntu 12.04.
@shanelharder:

You are absolutely right. I only skimmed the tutorial to try and see what you did. The Wordpress folder should be in /var/www and the paste you post does indeed confirm that it is. Very sorry! So yes,


sudo chown -R www-data:www-data /var/www


is correct.

As for being scared of the process, one of the great things about being able to take snapshots of your droplet and spin up temporary ones for pennies is that you can just test it out on a throw-away droplet with out worries. And always make a backup! =)
Try forcing it to use filesystem:
define( 'FS_METHOD', 'direct' ); in the wp-config.php file.

Also, chown the directory to the apache's username and group so it won't have permissions issues:
chown -R apache.apache public_html
Yeah its permissions issue. Change the ownership of the WordPress directory and all contents to the web server user as described above and you'll be able to update from within WordPress and add / updates plugins too.
Thanks a million!
According to your approach, I successfully solved the issue. thanks again!
Thanks, it works for me. I can upgrade directly from WP menu

Btw, could you elaborate this command? sudo chown -R www-data:www-data /path/to/WordPress_directory
I'll give it a spin -

"sudo" - executes the command as the root user on the server

"chown" - "change owner"

"-R" - recursive, drilling down to all child directories and files of the nominated file

"www-data:www-data" - specify the user and group to change the owner to - on Ubuntu, www-data is the name of the user that runs the web server process

"/path/to/Wordpress_directory" - simply the file path to the wordpress installation.

On the prebuilt DigitalOcean boxes, the file path will be something like /home/wordpress/public_html
Beauty! This solved my problem! Great explanation!
This is great solved my issue as well. Thanks for the help!
This sounds like a great solution. However, I am having a hard time finding the public.html file,
I followed this tutorial to install wordpress,
https://www.digitalocean.com/community/articles/how-to-install-wordpress-on-ubuntu-12-04
the root directory for wordpress is in var/www but i don't see public.html anywhere. What am I missing?
by Etel Sverdlov
Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality. This tutorial shows how to install Wordpress on a server with LAMP. It is written for Ubuntu 12.04.
@shanelharder: If you followed that tutorial, then your Wordpress folder should be in "~/wordpress/" so you'd run:


sudo chown -R www-data:www-data ~/wordpress/
Cool, worked like a charm, I can now quickly and easily update wordpress from within my WP dashboard with the automatic update option.

Great tip on the droplet snapshot! Not sure why I didn't think of that but I did that as well just to be safe and that process was pretty easy as well.

If anyone else is on Ubuntu 16.04 use sudo chown -R www-data:www-data /var/www. Updates work for me now

  • You might want to change that to

    sudo chown -R www-data:<username> /var/www/html 
    

    at the end to tighten up permissions.

Have another answer? Share your knowledge.