0

After cloning my wordpress site and fresh install of it i encountered problem. Plugins won't update. I'm working in Linux environment (Ubuntu). I've tried multiple solutions but still without positive result.

First of all i set all permissions for installation folder with chmod -R 777 .

Then i set define('FS_METHOD', 'direct');

After that i configured temp folder with :

define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/');
/* That's all, stop editing! Happy blogging. */

But still warning says that it can't find specified directory or is missing permissions.

I've also changed the owner of directory with chown -R $USER:$USER .

So now as ls -la says i'm the owner of the files and directories and i have full permissions to read, write and execute.

Now i run out of ideas what can cause such problem. Any help?

  • 1
    It is not you who should have those rights, but the user WordPress is running as (usually www-data in an Apache setup). – kero Oct 29 '18 at 15:43
  • Ok, i'll research this, and let you know if it works or not. – Bartosz Was Oct 29 '18 at 15:54
  • If you're updating the plugins from the Wordpress interface, the user account that is running PHP needs write access. In most LAMP configurations using mod_php the user is assigned from Apache www-data, apache, web, nobody are common variants. Others running php-fpm or suexec PHP can be run as a different user and group configuration. You can see who Apache is running as by using ps aux | egrep '(apache|httpd)' in the console on the webserver. Using chmod 777 is insecure, should only need chmod 750 on directories, chmod 640 on files of the apache user as owner and group. – fyrye Oct 29 '18 at 17:04
  • @fyrye by 'console on the webserver' you meant linux console? I type that and get this response httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP root 14885 0.0 0.1 351736 25644 ?. If it helps im using Lampp as server environment. – Bartosz Was Oct 29 '18 at 17:32
  • Curious if you created the wp-content/temp directory, since Wordpress will not automatically create it. That's a different output from ps aux than I am used to. From what it looks like, httpd is running as root. But there should have been more than one listing, since apache spawns different vhosts outside of the root process. – fyrye Oct 29 '18 at 17:46
0

I have Wordpress on Unbutu as well. Maybe this will get you started. (I'm assuming you have access with command line through Terminal via SSH. If that assumption is in error, forgive me.)

In a typical Wordpress install there are likely three users, similar to:

root:root 
www-data:www-data  (Apache)
user:user sudo lxd   (WHERE "user" is some name given for SSH access)

*Those users can be found by using the command: ps aux | grep apache

I've always found that the only way WP will update plugins, is if the ownership of plugins, and wp-uploads for media, is given to www-data... not the user. In fact I think I even go up to wp-content, then set ownership recursively. I set proper permissions to 755 for directories and 644 for files. (Never 777, that's bad).

(All my commands are done as sudo user, because I'm SSH-ing in Terminal as my user) Here are some options.

If you want to generically make Apache owner and set permissions on directories and files:

sudo chown www-data:www-data -R *  
sudo . -type d -exec chmod 755 {} \;  
sudo . -type f -exec chmod 644 {} \;  

If you want to specifically make Apache owner on a directory, and set permissions:

sudo chown www-data:www-data -R /var/www/html/wp-content/
sudo find /var/www/html/wp-content/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/wp-content/ -type f -exec chmod 644 {} \;

But if you set permissions on everything in the install directory to 777, you're going to want to fix that with something like:

sudo find /var/www/html/ -type d -exec -R chmod 755 {} \;
sudo find /var/www/html/ -type f -exec -R chmod 644 {} \;

Then make sure wp-config is hardened with 660 or even 600 permissions.

cd html
sudo chmod 660 wp-config.php
  • So following your guide i started to fix permissions after chmod 777 but my terminal says that /var/www directory does not exist. So i decided to do this step generically make Apache owner and set permissions on directories and files. Starting with command : sudo chown www-data:www-data -R * i can't process the next command sudo .-type d -exec chmod 755 {} \; and i get this response : sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set. Did i broke my filesystem? – Bartosz Was Oct 30 '18 at 10:21
0

First of all i set all permissions for installation folder with chmod -R 777 .

Mistakes happen, don't ever do the above again.

Please carefully follow my instructions. From within an Ubuntu VPS and you are at:

/var/www/mysite.com/public_html, run the following commands:

sudo chown -R yourName:www-data /var/www/mysite.com/

Next, run:

sudo find /var/www/mysite.com/ -type d -exec chmod 775 {} \;

That will give your directories the appropriate permissions and then do the same for your files like so:

sudo find /var/www/mysite.com/ -type f -exec chmod 664 {} \;

Once you have executed these commands you are golden, you have now hardened your WordPress site in accordance with the Principles of Least Privilege, but don't take my word for it, learn more here: https://codex.wordpress.org/Hardening_WordPress

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.