In storage, when creating a new directory and creating a file, use both root and nginx When user, an error is reported: fopen(/webtv/wangjie/ccp_api/images/ 2021/03/08/1615170408.5917.1243625051.png): Failed to Open Stream: Permission Denied
1. When running a command line script, use root User-created directory: /webtv/wangjie/ccp_api/images/2021/03/08, create file: 1615170036.5115.2027450777.png. The owner of the directory and the group to which it belongs are root. as shown in Figure 1
2. When running the HTTP interface, use the nginx user in the directory: /webtv/wangjie/ccp_api/images/2021/03/08 Create the file below: 1615170408.5917.1243625051.png. Error: fopen(/webtv/wangjie/ccp_api/images/2021/03/08/1615170408.5917.1243625051.png): Failed to open stream: Permission denied. as shown in Figure 2
3. Finally, after creating the directory, modify the owner of the directory and the group to which it belongs to nginx. as shown in Figure 3
// return chmod($path, $mode);
@chmod($path, $mode);
$user = 'nginx';
@chown($path, $user);
@chgrp($path, $user);
return true;
4. Delete the directory: /webtv/wangjie/ccp_api/images/2021/03/08. When running a command line script, use root User-created directory: /webtv/wangjie/ccp_api/images/2021/03/08, create file: 1615173793.3843.742805318.png. The owner of the directory and the group to which it belongs is nginx. in line with expectations. as shown in Figure 4
5. When running the HTTP interface, use the nginx user in the directory: /webtv/wangjie/ccp_api/images/2021/03/08 Create the file below: 1615173932.3359.493433255.png Success. in line with expectations. as shown in Figure 5
6. When running the HTTP interface, use Nginx The user creates the directory: /webtv/wangjie/ccp_api/images/2021/03/10, create file: 1615340979.3862.490335317.png. The owner of the directory and the group to which it belongs is nginx. in line with expectations. as shown in Figure 6
7. When running the command line script, use the root user in the directory: /webtv/wangjie/ccp_api/images/2021/03/10 Create the file below: 1615341025.4625.492305521.png Successfully. in line with expectations. as shown in Figure 7






