From the previous article: PHP website (nginx, PHP-FPM, MySQL) User rights analysis, you can learn how Nginx and PHP-FPM users are working.
There is a working scenario:
1, the company has a CentOS server running several websites, each site is maintained by different teams, if you make sure that the FTP update files, do not update the wrong, not disorderly channeling. How to avoid the original to a site update files, the results uploaded to the B site, and so on chaos like;
2, only with the use of CentOS with SFTP, do not intend to install VSFTPD and other third-party FTP software;
3, the Site Directory reference is as follows:
/usr/local/nginx/www/test.cnblogs.com
/usr/local/nginx/www/www.cnblogs.com
Solution:
1, the website user (nginx,php-fpm,ftp user) all belong to the WWW user group;
2, nginx,php-fpm all use the user www;
3. Create a new independent FTP user for each website;
4, each website, FTP user has read, write, execute the permission, php-fpm the user only read, execute the permission (individual cache file/folder open Write permission);
5. The reference code is as follows:
##################################################### Modify site www.cnblogs.com directory permissions ################################## ################# new Account Useradd ftp_cnblogs_www-g wwwpasswd ftp_cnblogs_www # Password: ftp_cnblogs_www_123# Modify Permissions Chown-r Ftp_cnblogs_www:www/usr/local/nginx/www/www.cnblogs.comchmod-r 750/usr/local/nginx/www/www.cnblogs.comchmod-r 760/usr/local/nginx/www/www.cnblogs.com/datachmod-r 760/usr/local/nginx/www/www.cnblogs.com/write2.txt######### ############################################ Modify site test.cnblogs.com directory permissions ########################################## ######### new Account Useradd ftp_cnblogs_test-g wwwpasswd ftp_cnblogs_test # Password: ftp_cnblogs_test_123# Modify Permissions Chown-r ftp_ Cnblogs_test:www/usr/local/nginx/www/test.cnblogs.comchmod-r 750/usr/local/nginx/www/test.cnblogs.comchmod-r 760 /usr/local/nginx/www/test.cnblogs.com/datachmod-r 760/usr/local/nginx/www/test.cnblogs.com/write2.txt
Note:SFTP itself has other aspects of the security configuration, such as allowing users to only access their home directory,,, interested students can go under the study!
"Recommended" How to plan Nginx Site Directory permissions (user, user group, SSH,SFTP)