Failed to reset Wordpress permission for wp-config.php file from 777 to 640

Keywords: WordPress - Google Cloud Platform - Technical issue - Permissions

bnsupport ID: 67353d31-ddc1-3086-33a7-fdbed67b02f8

bndiagnostic output:

? Resources: Found possible issues

bndiagnostic failure reason: The suggested guides are not related with my issue

Description:
Hi,
I would like to change the permission for the wp-config.php file from 777 back to 640. I tried to change it to 775 or 664 but all failed for this particular file.

I ran the below command which changed the permission to 777 to install a plugin.
sudo chown daemon:daemon /opt/bitnami/wordpress/wp-config.php

I tried the below command but couldn’t reset the permission back to 640, it stays as 777
sudo chown -R bitnami:daemon /opt/bitnami/wordpress
sudo find /opt/bitnami/wordpress -type d -exec chmod 775 {} ;
sudo find /opt/bitnami/wordpress -type f -exec chmod 664 {} ;
sudo chmod 640 /opt/bitnami/wordpress/wp-config.php

Below is the stat of the wp-config.php file for your reference.
File: /opt/bitnami/wordpress/wp-config.php -> /bitnami/wordpress/wp-config.php
Size: 32 Blocks: 0 IO Block: 4096 symbolic link
Device: 801h/2049d Inode: 405493 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ bitnami) Gid: ( 1/ daemon)

Many thanks for your help in advance,
Linh

Hello @calmista.info,

Note that /opt/bitnami/wordpress/wp-config.php is a symbolic link to /bitnami/wordpress/wp-config.php: Try this command:

sudo chmod 640 /bitnami/wordpress/wp-config.php

I hope it helps

Hi @davidg

Thanks much, I ran the command you suggested. I got two different permission status as below. Is it normal?

sudo stat /bitnami/wordpress/wp-config.php
File: /bitnami/wordpress/wp-config.php
Size: 4516 Blocks: 16 IO Block: 4096 regular file
Device: 801h/2049d Inode: 139190 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1/ daemon) Gid: ( 1/ daemon)

sudo stat /opt/bitnami/wordpress/wp-config.php
File: /opt/bitnami/wordpress/wp-config.php -> /bitnami/wordpress/wp-config.php
Size: 32 Blocks: 0 IO Block: 4096 symbolic link
Device: 801h/2049d Inode: 405493 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1000/ bitnami) Gid: ( 1/ daemon)

Hello @calmista.info,

that’s correct. I have checked defaults permissions on a clean installation:

david@bitnami-wordpress-b182:~$ sudo stat /bitnami/wordpress/wp-config.php
  File: /bitnami/wordpress/wp-config.php
  Size: 4410            Blocks: 16         IO Block: 4096   regular file
Device: 801h/2049d      Inode: 137755      Links: 1
Access: (0640/-rw-r-----)  Uid: ( 1000/ bitnami)   Gid: (    1/  daemon)

david@bitnami-wordpress-b182:~$ sudo stat /opt/bitnami/wordpress/wp-config.php
  File: /opt/bitnami/wordpress/wp-config.php -> /bitnami/wordpress/wp-config.php
  Size: 32              Blocks: 0          IO Block: 4096   symbolic link
Device: 801h/2049d      Inode: 404480      Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-10-13 08:22:04.417053799 +0000

Note that the owner is bitnami:daemon and for the symbolic link owner is root:root and
Regards

Many thanks! Would I need to update the owners to match the original setting for the permission to work or it should work based on the 640 number already?

Hi @calmista.info,

You are welcome. It should work because daemon (apache) can read it, but my suggestion is to use default permissions.

Regards