Setting correct permission for Docker PHP-FPM on mounted folder

Now, if you have followed my guide on setting up Docker with PHP-FPM then you'll most likely face this issue where your files and directories permission will have to set to 777 in order for docker to write files to your mounted folder.

In order to resolve this, you'll need to reset your 777 mistakes using the command given in my reset files/directories permission article.

Once you've done that, you'll be back to your square one where your application can't write to your mounted folder.

Now, in your mounted folder assuming its in /root/www you'll need to look for the user that exec your php script in your php-fpm docker. By default its www-data (dahhh). So let's find out what this user id is on the parent machine by firing the following docker command

docker exec phpfpm id www-data

where phpfpm is the docker name of your PHP-FPM container. If you are not using PHP-FPM on a separate container, you can easily just replace phpfpm to your LEMP/LAMP docker container name.

and the above will show you something like this

root@php:~# docker exec phpfpm id www-data
uid=82(www-data) gid=82(www-data) groups=82(www-data),82(www-data)

the above means that on the parent machine, the user id for www-data is 82. Now, go ahead and change the user permission on your mounted folder to 82 with the following command

chown 82:82 -r /root/www

where /root/www is the example mounted folder used in this article.

Now, with the correct user permission, your application should be able to write correctly without the need to set your directories permissions to 777 which is pretty insecure.

Hope this helps.

Set Default Secure Files / Directories Permission on cPanel / Linux

In cPanel, if you accidentally alter the wrong files or directories' permission, you'll most likely get a 500 error. This is mainly due to the usage of SuPHP in your cPanel setup. Now, the below, snippets are pretty useful to reset or secure the permissions needed for both files and directories.

In order to reset your directories' permission. You'll need to fire the below command.

find . -type d -exec chmod 755 {} \;

where the above find all the directory on your current directory and exec permission 755 on it

In order to reset your files' permission. You'll need to fire the below command.

find . -type f -exec chmod 755 {} \;

where the above find all the files on your current directory and exec permission 755 on it.

In order to fix your cPanel account file permission issue. All you need to do is to fire the above 2 commands on the directory on your user account lets say hungred as shown below,

cd /home/hungred/public_html/

where hungred is your user account. Hope this helps.

cman gets stucked on unmounting configfs

well, once again i got stuck when my cluster suddenly doesn't work and i need to figure out why without restarting my server. restarting cman always throw me a stuck "Unmounting configfs..."

/etc/init.d/cman restart
Stopping cluster:
   Stopping dlm_controld... [  OK  ]
   Stopping fenced... [  OK  ]
   Stopping cman... [  OK  ]
   Unloading kernel modules... [  OK  ]
   Unmounting configfs...

running service cman status i get the following

service cman status
Found stale pid file

now i tried to stop all services that may caused this but apparently it was because the cluster is still running, hence, it wasn't able to unmount configfs

/etc/init.d/pve-cluster stop

once i've stopped my pve cluster. i tried restarting cman again

/etc/init.d/cman restart
Stopping cluster:
   Stopping dlm_controld... [  OK  ]
   Stopping fenced... [  OK  ]
   Stopping cman... [  OK  ]
   Unloading kernel modules... [  OK  ]
   Unmounting configfs... [  OK  ]
Starting cluster:
   Checking if cluster has been disabled at boot... [  OK  ]
   Checking Network Manager... [  OK  ]
   Global setup... [  OK  ]
   Loading kernel modules... [  OK  ]
   Mounting configfs... [  OK  ]
   Starting cman... [  OK  ]
   Waiting for quorum... [  OK  ]
   Starting fenced... [  OK  ]
   Starting dlm_controld... [  OK  ]
   Tuning DLM kernel config... [  OK  ]
   Unfencing self... [  OK  ]

now my cman starts running again i can start my cluster again

/etc/init.d/pve-cluster restart
Restarting pve cluster filesystem: pve-cluster.

just to make sure everything works, you can run the following

service cman status
cluster is running.

now i don't have to restart my server in order to get my cluster running again. Hope this helps!

SMTP Auth – SMTP Relay

If you are getting an error with the following error

SMTP error from remote mail server after RCPT TO:<admin @domain.com>: 550 smtp auth requried

from the script that is running on your server but the domain.com isn't locate on the same physical machine. You are most likely doing a SMTP Relay and your exim isn't really happy with not having authentication credential being provided.

In this case, you can just add the following to your exim.conf file, assuming 123.123.123.123 is your script server,

domainlist local_domains = dsearch;/etc/exim4/domains/
domainlist relay_to_domains = dsearch;/etc/exim4/domains/
hostlist relay_from_hosts = 127.0.0.1 : 123.123.123.123
hostlist whitelist = net-iplsearch;/etc/exim4/white-blocks.conf
hostlist spammers = net-iplsearch;/etc/exim4/spam-blocks.conf

you can also placed 123.123.123.123 into the file /etc/exim4/white-blocks.conf to whitelist the host on your server.

you might also need to add auth_advertise_hosts = * as show below,

host_lookup = *
auth_advertise_hosts = 123.123.123.123
rfc1413_hosts = *

which expand to all host other than localhost (of course, you might want to change it to ip instead of *)

this should allows your script to sent email using your smtp server as a relay without the need for authentication.

WordPress libgomp: Thread creation failed: Resource temporarily unavailable

Another fresh issue, pretty straight forward but if you are facing this issue with the error in apache saying

libgomp: Thread creation failed: Resource temporarily unavailable, referer: https://xxxxx.org/wp-admin/media-new.php

this is most likely due to your server limit has been reached either by user level or root level. The quickest way to resolve this temporary is to increase your soft limit as shown below,

ulimit -s 999999

once you've done that. you should try upload file in WordPress and you shouldn't see the HTTP Error message. but to make this permanent after you've reboot.

Open the file located at vi /etc/security/limits.d/90-nproc.conf

*          soft    nproc     999999
root       soft    nproc     unlimited

update and change the value u see above and it should do the trick. If this doesn't do the trick, you might want to try adding the following to your .htaccess

SetEnv MAGICK_THREAD_LIMIT 1

This happens when the full installation of ImageMagick cannot be done which causes the HTTP Error to show.