I have a limited understanding of MySQL's interaction with my CentOS 7 server and need some help.
Basically, I have a WordPress installation and I need to set the uploads directory and all directories within to CHMOD 777 to upload images via the backend. CHMOD 775 doensn't work though. This baffled me and is something I am not willing to do as I unserstand the risks and how easily it can be exploited. I would be giving public write permissions in that folder and that is bad right?
My database user has privileges to the database and the database connects. The website works minus writing part. Now what I don't understand is how the MySQL user relates to the local CentOS user at all. I don't believe that is linked anywhere and if I am wrong how would i do that?
The reason I am thinking this is due to the CHMOD 775 not working meaning that the said database user is not a user or a member of the group required to have said access and to be able to write. Hence why I need local write permissions enabled.
===================================================
OS: CentOS 7 , Server: Nginx , Database: MariaDB , PHP: PHP 5.4.3
Local User Directory: /home - CHMOD 755, CHOWN root:root
Local Users /home/usr1 - CHMOD 501, CHOWN usr1:usr1 , /home/usr2 - CHMOD 501, CHOWN usr2:usr2
Contains Website WWW: /home/usr1/www - CHMOD 775, CHOWN usr1:usr1 , /home/usr2/www - CHMOD 775, CHOWN usr2:usr2
Rest of Files/Directories: CHOWN usr1:usr1 for all files in WWW , CHOWN usr2:usr2 for all files in his respective WWW
CHOWN 775 for all directories in WWW
So when I connect the database to the wordpress installation, how in the heck does it know to use root, usr1 or usr2. I tried putting them all in a group to see what happens but it didn't work. Thought it was worth a shot.
Any help, advice, education and so and so forth is appreciated. Help me if you can please :)
==================================================
chown apache:apache wp-content
.... did the trick. A good way to see the user is to set file permission to 777 in uploads and all directories with aka recursively. Check the owner of the uploaded file and voila, chown (to that owner).
Also the user is not set by nginx.conf in my case. It is set by php.ini and whoever down voted this is an idiot.
Further clarfication as PassKit seems to not understand: Yes DO NOT SET 777 permissions. It is just a temporary solution so you can then go and check who the server is using to write files. After setting 777 permissions and uploading your file immediately change the permissions to 775 or 755 if on shared hosting.