I am having problem that apache can't write file via PHP (for example, write csv file) - I have to change file permission to 777 and it work but it is very bad security. I am trying to use sufficient permissions to write, maybe 664. What went wrong?
Apache is running as apache
and group is also apache
. All the files in /var/www/html
are owned by root and group is web-content
I can login to FTP client and read/write files to /var/www/html
without any problem.
I have created an ftp user called intranet, here what I did:
groupadd web-content
usermod -G web-content intranet
chown root:web-content /var/www/html
chmod o+rx /var/www/html
find /var/www/html -type f -exec chmod 0664 {} \;
find /var/www/html -type d -exec chmod 0775 {} \;
ls -la /var/www/
drwxrwxr-x. 4 root web-content 4.0K Sep 6 16:09 html
When I upload new files on FTP.
ls -la /var/www/intranet/
-rw-r--r--. 1 intranet intranet 0 Sep 6 17:42 test