Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Unable to update WordPress due to incorrect file permission
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Unable to update WordPress due to incorrect file permission

aliletalilet Member

I am getting error while updating plugin. This is Oracle Linux Arm Ampere instance.

An error occurred while updating Akismet Anti-Spam: Could not create directory.

I have applied following permission on files and folders.

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

I have another WordPress site on VirMach VPS with same permission and there it updates fine. Here's result of ls -l

[opc@arm html]$ ls -l
total 212
-rw-r--r--  1 nginx nginx   405 Feb  6  2020 index.php
-rw-r--r--  1 nginx nginx 19915 Jan  1  2022 license.txt
-rw-r--r--  1 nginx nginx  7401 Mar 22 21:11 readme.html
-rw-r--r--  1 nginx nginx  7165 Jan 21  2021 wp-activate.php
drwxr-xr-x  9 nginx nginx  4096 Jul 12 16:16 wp-admin
-rw-r--r--  1 nginx nginx   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 nginx nginx  2338 Nov  9  2021 wp-comments-post.php
-rw-r--r--  1 nginx nginx  3230 Aug 18 17:53 wp-config.php
drwxr-xr-x  4 nginx nginx    52 Jul 12 16:16 wp-content
-rw-r--r--  1 nginx nginx  3943 Apr 28 09:49 wp-cron.php
drwxr-xr-x 26 nginx nginx 12288 Jul 12 16:16 wp-includes
-rw-r--r--  1 nginx nginx  2494 Mar 19 20:31 wp-links-opml.php
-rw-r--r--  1 nginx nginx  3973 Apr 12 01:47 wp-load.php
-rw-r--r--  1 nginx nginx 48498 Apr 29 14:36 wp-login.php
-rw-r--r--  1 nginx nginx  8577 Mar 22 16:25 wp-mail.php
-rw-r--r--  1 nginx nginx 23706 Apr 12 09:26 wp-settings.php
-rw-r--r--  1 nginx nginx 32051 Apr 11 11:42 wp-signup.php
-rw-r--r--  1 nginx nginx  4748 Apr 11 11:42 wp-trackback.php
-rw-r--r--  1 nginx nginx  3236 Jun  8  2020 xmlrpc.php

Site Health in WordPress says:

Shows whether WordPress is able to write to the directories it needs access to.

The main WordPress directory    Not writable
The wp-content directory    Not writable
The uploads directory   Not writable
The plugins directory   Not writable
The themes directory    Not writable

But the other site on VirMach VPS says these folders are writeable.

SELinux is disabled.

Comments

  • What's the nginx user? maybe www-data or something else?

  • @luckypenguin said:
    What's the nginx user? maybe www-data or something else?

    user is nginx as defined in /etc/nginx/nginx.conf

  • So go a little upper, chown -R nginx:nginx /var/www and same for chmods.

  • The only way it is working if I set all files and folders to 777

  • @alilet said: The only way it is working if I set all files and folders to 777

    Shouldn't be the case. Try with
    find . -type d -exec chmod 775 {} \;
    find . -type f -exec chmod 664 {} \;

    Should be sufficient enough. What's your general umask for /var ?

  • amarcamarc Veteran

    Probably your PHP is running as other user.. so that is why. Investigate that part and chmod to that user

  • maybe your php-fpm is running as www-data?

  • @luckypenguin said:

    @alilet said: The only way it is working if I set all files and folders to 777

    Shouldn't be the case. Try with
    find . -type d -exec chmod 775 {} \;
    find . -type f -exec chmod 664 {} \;

    Should be sufficient enough. What's your general umask for /var ?

    Using 775 also doesn't work. I don't know how to check usmak for /var but when I login to VPS and do usmak on root folder then I get 0002

    [opc@arm ~]$ umask
    0002
    
  • aliletalilet Member
    edited August 2022

    @amarc said:
    Probably your PHP is running as other user.. so that is why. Investigate that part and chmod to that user

    /etc/php-fpm.d shows that php-fpm is running as www

    ; Start a new pool named 'www'.
    ; the variable $pool can be used in any directive and will be replaced by the
    ; pool name ('www' here)
    [www]
    

    When I do following then it says invalid user
    sudo chown -R www:www /var/www/mysite/html

  • amarcamarc Veteran

    You need to hire someone to manage that for you or go with fully managed host. Sooner or later it will bite you.

    https://www.digitalocean.com/community/tutorials/php-fpm-nginx

  • YmpkerYmpker Member
    edited August 2022

    @amarc said:
    You need to hire someone to manage that for you or go with fully managed host. Sooner or later it will bite you.

    https://www.digitalocean.com/community/tutorials/php-fpm-nginx

    Just go with a decent Shared Hosting Provider. I made the switch years away from VPS years ago and wouldn't wanna go back. Currently happy with @MikePT hosting :) Brixly is great, too.

    HostMantis were having stellar performance before the buyout, too. Ramnode was great before the takeover. Unfortunately, these two are probably out.

    Thanked by 1MikePT
  • aliletalilet Member
    edited August 2022

    Found and fixed the issue. I compared www.conf of both VPS and noticed the following:

    Debian 11 on VirMach
    sudo nano /etc/php/8.1/fpm/pool.d/www.conf
    user = www-data
    group = www-data

    Oracle Linux 8 on Oracle Cloud
    sudo nano /etc/php-fpm.d/www.conf
    user = apache
    group = apache

    Aha so the user is actually apache and not nginx as I thought. So running following command fixed the issue.

    sudo chown -R apache:apache /var/www/mysite/html

  • @alilet said: Aha so the user is actually apache and not nginx as I thought. So running following command fixed the issue.

    But then nginx won't be able to write there, when you need it to outside PHP env.
    Anyway it's a trivial issue, but how comes you have different setups from your "master"
    working setup? Do you install nginx+php+mysql from the provider scripts/manuals?
    That's a big potential mistake as it will put you into an issue like above in the future.

  • @luckypenguin said:

    @alilet said: Aha so the user is actually apache and not nginx as I thought. So running following command fixed the issue.

    But then nginx won't be able to write there, when you need it to outside PHP env.
    Anyway it's a trivial issue, but how comes you have different setups from your "master"
    working setup? Do you install nginx+php+mysql from the provider scripts/manuals?
    That's a big potential mistake as it will put you into an issue like above in the future.

    The only difference in installation is in pfp-fpm on both VPS.

    On Debian 11 I installed pfp fpm 8.1 using following:

    sudo apt-get install ca-certificates apt-transport-https software-properties-common wget curl lsb-release -y
    curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x
    sudo apt update
    sudo apt upgrade
    sudo apt install php8.1-fpm

    On Oracle Linux 8 I installed php fpm 8.0 as follows (couldn't find 8.1)
    sudo dnf module enable php:8.0
    sudo yum install php-fpm

    In addition to that there are slight differences in both server's nginx conf file. On Debain 11 the user in nginx conf is www-data. On Oracle Linux 8 the user in nginx conf is nginx

  • @alilet said: On Debain 11 the user in nginx conf is www-data. On Oracle Linux 8 the user in nginx conf is nginx

    My first post was suggesting this, I assumed you checked both nginx and fpm for that.
    Happy it worked out for you :)

    Thanked by 1alilet
  • @luckypenguin said:

    @alilet said: On Debain 11 the user in nginx conf is www-data. On Oracle Linux 8 the user in nginx conf is nginx

    My first post was suggesting this, I assumed you checked both nginx and fpm for that.
    Happy it worked out for you :)

    Yeah. And I went to check user in nginx conf which was nginx. Didn't realize I also need to check user in php-fpm config which is different.

  • amarcamarc Veteran

    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Thanked by 2vyas11 alilet
  • @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    I concur on the DRP!!!

    OP might benefit with someone to manage matters for them, but then there an element of fun n' learn in Do It Yourself. Let us now discount that.

    Of course, CWP or any other panel might be a preferred way to start before diving in the deep end of the pool, so to speak.

  • MikePTMikePT Moderator, Patron Provider, Veteran

    @Ympker said:

    @amarc said:
    You need to hire someone to manage that for you or go with fully managed host. Sooner or later it will bite you.

    https://www.digitalocean.com/community/tutorials/php-fpm-nginx

    Just go with a decent Shared Hosting Provider. I made the switch years away from VPS years ago and wouldn't wanna go back. Currently happy with @MikePT hosting :) Brixly is great, too.

    HostMantis were having stellar performance before the buyout, too. Ramnode was great before the takeover. Unfortunately, these two are probably out.

    Thanks mate! <3

    Thanked by 1Ympker
  • @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Will look into it. I am a Linux noob so I have made a .txt file containing all commands and procedures and if I have to rebuild VPS then I just run them one by one. Been running a WooCommerce website for 3 years and so far no issues but will check this user/permission isolation.

  • emghemgh Member

    @alilet said:

    @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Will look into it. I am a Linux noob so I have made a .txt file containing all commands and procedures and if I have to rebuild VPS then I just run them one by one. Been running a WooCommerce website for 3 years and so far no issues but will check this user/permission isolation.

    At least use a WP stack? EasyEngine?

    Thanked by 1alilet
  • @emgh said:

    @alilet said:

    @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Will look into it. I am a Linux noob so I have made a .txt file containing all commands and procedures and if I have to rebuild VPS then I just run them one by one. Been running a WooCommerce website for 3 years and so far no issues but will check this user/permission isolation.

    At least use a WP stack? EasyEngine?

    WP Stack looks like a website/blog where you can read articles about WP and its configuration. Just checked EasyEngine and it doesn't support Debain 11 as well no PHP 8 support.

  • emghemgh Member
    edited August 2022

    @alilet said:

    @emgh said:

    @alilet said:

    @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Will look into it. I am a Linux noob so I have made a .txt file containing all commands and procedures and if I have to rebuild VPS then I just run them one by one. Been running a WooCommerce website for 3 years and so far no issues but will check this user/permission isolation.

    At least use a WP stack? EasyEngine?

    WP Stack looks like a website/blog where you can read articles about WP and its configuration. Just checked EasyEngine and it doesn't support Debain 11 as well no PHP 8 support.

    Well, with the time you save using it, you could learn how to research better. At least, you were about 33 % right.

    Thanked by 1vyas11
  • @emgh said:

    @alilet said:

    @emgh said:

    @alilet said:

    @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Will look into it. I am a Linux noob so I have made a .txt file containing all commands and procedures and if I have to rebuild VPS then I just run them one by one. Been running a WooCommerce website for 3 years and so far no issues but will check this user/permission isolation.

    At least use a WP stack? EasyEngine?

    WP Stack looks like a website/blog where you can read articles about WP and its configuration. Just checked EasyEngine and it doesn't support Debain 11 as well no PHP 8 support.

    Well, with the time you save using it, you could learn how to research better. At least, you were about 33 % right.

    Live and learn, mon ami.. live and learn

    Happy Friday.

    Thanked by 1emgh
  • emghemgh Member

    @vyas11 said:

    @emgh said:

    @alilet said:

    @emgh said:

    @alilet said:

    @amarc said:
    Plot twist: you should never run PHP as privileged user (www, www-data, apache or what not..).

    Also, did you just curl'd some README.txt and executed it ?

    "We recommend to activate your Disaster Recovery Plan"

    Will look into it. I am a Linux noob so I have made a .txt file containing all commands and procedures and if I have to rebuild VPS then I just run them one by one. Been running a WooCommerce website for 3 years and so far no issues but will check this user/permission isolation.

    At least use a WP stack? EasyEngine?

    WP Stack looks like a website/blog where you can read articles about WP and its configuration. Just checked EasyEngine and it doesn't support Debain 11 as well no PHP 8 support.

    Well, with the time you save using it, you could learn how to research better. At least, you were about 33 % right.

    Live and learn, mon ami.. live and learn

    Happy Friday.

    You too.

Sign In or Register to comment.