copy: failed to open stream: Permission denied

1、copy(/webtv/wangjie/channel-pub-api/images/2020/08/26/1598426506.2121.2009434638.jpeg): failed to open stream: Permission denied。如图1

copy(/webtv/wangjie/channel-pub-api/images/2020/08/26/1598426506.2121.2009434638.jpeg): failed to open stream: Permission denied。

图1

2020-08-26 16:05:11 [10.42.2.229][-][-][error][yii/base/ErrorException:2] yii/base/ErrorException: copy(/webtv/wangjie/channel-pub-api/images/2020/08/26/1598429111.0583.1328310233.jpeg): failed to open stream: Permission denied in /mcloud/www/channel-pub-api/common/services/AssetService.php:207
Stack trace:
#0 [internal function]: yii/base/ErrorHandler->handleError(2, 'copy(/webtv/wan...', '/mcloud/www/cha...', 207, Array)
#1 /mcloud/www/channel-pub-api/common/services/AssetService.php(207): copy('/webtv/wangjie/...', '/webtv/wangjie/...')
#2 /mcloud/www/channel-pub-api/wx/services/WxArticleMassService.php(80): common/services/AssetService::copyAssetsSync('spider', Array)
#3 /mcloud/www/channel-pub-api/wx/rests/wx_article/ArticleAction.php(118): wx/services/WxArticleMassService->publishNewsArticle(Array)
#4 [internal function]: wx/rests/wx_article/ArticleAction->standardArticle(Array, 'mass')
#5 /mcloud/www/channel-pub-api/wx/rests/wx_article/ArticleAction.php(76): call_user_func(Array, Array, 'mass')
#6 [internal function]: wx/rests/wx_article/ArticleAction->run()
#7 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)
#8 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Controller.php(157): yii/base/Action->runWithParams(Array)
#9 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Module.php(528): yii/base/Controller->runAction('article', Array)
#10 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/web/Application.php(103): yii/base/Module->runAction('v1/wx-article/a...', Array)
#11 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Application.php(386): yii/web/Application->handleRequest(Object(yii/web/Request))
#12 /mcloud/www/channel-pub-api/wx/web/index.php(17): yii/base/Application->run()
#13 {main}
2020-08-26 16:05:11 [10.42.2.229][-][-][warning][yii/debug/Module::checkAccess] Access to debugger is denied due to IP address restriction. The requesting IP address is 10.42.2.229
2020-08-26 16:05:11 [10.42.2.229][-][-][info][application] $_GET = [
    'group_id' => 'spider'
]

$_POST = [
    'app_ids' => [
        0 => 'af2dfa72e29111eaa8ec8471dcec4058'
    ]
    'code' => 'standard'
    'thumb' => 'https://mserver.chinamcloud.cn/cms/mrzd/upload/Image/MRLM/2020/08/26/1_12f10c372509417a904a96a1563d59ca.jpeg'
    'author' => '大兵小将Big Or Small'
    'source_article_id' => '265042'
    'source_pub_user_id' => '11111'
    'material_list' => '[{/"type/":/"video/",/"url/":/"https://mserver.chinamcloud.cn/vms/video/default/vod/2020/08/25/eea43bcdf8454dde8b7ef9b73ad7be4a/eea43bcdf8454dde8b7ef9b73ad7be4a_h264_1200k_mp4.mp4/",/"tag/":/"video/",/"title/":/"555555555555555555/",/"article_category_id/":226}]'
    'description' => 'wjtest->default'
    'source_uuid' => '8d44142324ed4ee69427804c5f1823e5'
    'source' => 'spider'
    'title' => '555555555555555555'
    'content' => '<div style=/"font-size:18px;line-height:1.5;/" id=/"editWrap/">
 <div id=/"editWrap/" style=/"font-size:18px;line-height: 1.5em;color:#000000;/">
  <p class=/"zwf/"><img></p>
  <p style=/"text-align:center/">
   <video controls=/"controls/" class=/"videoInfo/" class1=/"videoInfo/" id=/"eea43bcdf8454dde8b7ef9b73ad7be4a/" type=/"5/" title=/"272m/" duration=/"00:04:05/" src=/"https://mserver.chinamcloud.cn/vms/video/default/vod/2020/08/25/eea43bcdf8454dde8b7ef9b73ad7be4a/eea43bcdf8454dde8b7ef9b73ad7be4a_h264_1200k_mp4.mp4/" preload=/"preload/" poster=/"https://mserver.chinamcloud.cn/vms/pic/default/upload/Image/default/2020/08/25/eea43bcdf8454dde8b7ef9b73ad7be4a/0_640_400_3073.jpg/" style=/"max-width: 100%;max-height: 350px;background: #000;/" createtime=/"2020-08-25/"></video></p>
  <p class=/"zwf/"><br></p>
  <p><br></p>
 </div>
</div>'
    'url' => 'https://mserver.chinamcloud.cn/cms/mrzd/zmt/flal/dbdjsoldier/265042.shtml'
    'wx_send_type' => 'mass'
    'source_callback_url' => 'https://scms.wjtest.chinamcloud.cn/api/thirdPush/callBack'
    'tag' => 'video'
]

$_FILES = []

$_COOKIE = []

$_SERVER = [
    'USER' => 'nginx'
    'HOME' => '/var/cache/nginx'
    'HTTP_CONNECTION' => 'close'
    'HTTP_X_FORWARDED_FOR' => '188.131.147.50'
    'HTTP_X_FORWARDED_PORT' => '80'
    'HTTP_CONTENT_LENGTH' => '2111'
    'HTTP_HOST' => 'channelpubapi.wjtest.chinamcloud.cn'
    'HTTP_USER_AGENT' => 'Jakarta Commons-HttpClient/3.1'
    'HTTP_CONTENT_TYPE' => 'application/x-www-form-urlencoded'
    'HTTP_ACCEPT_ENCODING' => 'gzip,deflate,br'
    'HTTP_ACCEPT_LANGUAGE' => 'zh-CN'
    'HTTP_ACCEPT' => 'application/json;version=0.0'
    'SCRIPT_FILENAME' => '/mcloud/www/channel-pub-api/wx/web/index.php'
    'REDIRECT_STATUS' => '200'
    'SERVER_NAME' => 'channelpubapi.wjtest.chinamcloud.cn'
    'SERVER_PORT' => '80'
    'SERVER_ADDR' => '10.42.222.158'
    'REMOTE_PORT' => '42812'
    'REMOTE_ADDR' => '10.42.2.229'
    'SERVER_SOFTWARE' => 'nginx/cnginx'
    'GATEWAY_INTERFACE' => 'CGI/1.1'
    'REQUEST_SCHEME' => 'http'
    'SERVER_PROTOCOL' => 'HTTP/1.1'
    'DOCUMENT_ROOT' => '/mcloud/www/channel-pub-api'
    'DOCUMENT_URI' => '/wx/web/index.php'
    'REQUEST_URI' => '/wx/v1/wx-articles/article?group_id=spider'
    'SCRIPT_NAME' => '/wx/web/index.php'
    'CONTENT_LENGTH' => '2111'
    'CONTENT_TYPE' => 'application/x-www-form-urlencoded'
    'REQUEST_METHOD' => 'POST'
    'QUERY_STRING' => 'group_id=spider'
    'FCGI_ROLE' => 'RESPONDER'
    'PHP_SELF' => '/wx/web/index.php'
    'REQUEST_TIME_FLOAT' => 1598429110.9021
    'REQUEST_TIME' => 1598429110
]

2、进入目录:/webtv/wangjie/channel-pub-api/images/2020/08,查看权限,发现 26 的目录,其用户与用户组为 root。由于今天程序升级,生成目录的用户与用户组发生了变化。决定删除目录:26。再次基于接口来生成目录:26。未再报错,如图2

进入目录:/webtv/wangjie/channel-pub-api/images/2020/08,查看权限,发现 26 的目录,其用户与用户组为 root。由于今天程序升级,生成目录的用户与用户组发生了变化。决定删除目录:26。再次基于接口来生成目录:26。未再报错,

图2

[root@04302a060834 logs]# cd /webtv/wangjie/channel-pub-api/images/2020/08
[root@04302a060834 08]# ls -l
total 24
drwxrwxr-x 2 nginx nginx 4096 Aug  1 17:17 01
drwxrwxr-x 2 nginx nginx 4096 Aug  2 10:06 02
drwxrwxr-x 2 nginx nginx 4096 Aug  3 21:11 03
drwxrwxr-x 2 nginx nginx 4096 Aug  5 15:45 05
drwxrwxr-x 2 nginx nginx 4096 Aug  7 11:33 07
drwxrwxr-x 2 nginx nginx   91 Aug 21 17:02 21
drwxrwxr-x 2 nginx nginx  102 Aug 25 14:59 25
drwxrwxr-x 2 root  root  4096 Aug 26 13:33 26
[root@04302a060834 08]# rm -rf 26
[root@04302a060834 08]# ls -l
total 20
drwxrwxr-x 2 nginx nginx 4096 Aug  1 17:17 01
drwxrwxr-x 2 nginx nginx 4096 Aug  2 10:06 02
drwxrwxr-x 2 nginx nginx 4096 Aug  3 21:11 03
drwxrwxr-x 2 nginx nginx 4096 Aug  5 15:45 05
drwxrwxr-x 2 nginx nginx 4096 Aug  7 11:33 07
drwxrwxr-x 2 nginx nginx   91 Aug 21 17:02 21
drwxrwxr-x 2 nginx nginx  102 Aug 25 14:59 25
[root@04302a060834 08]# ls -l
total 20
drwxrwxr-x 2 nginx nginx 4096 Aug  1 17:17 01
drwxrwxr-x 2 nginx nginx 4096 Aug  2 10:06 02
drwxrwxr-x 2 nginx nginx 4096 Aug  3 21:11 03
drwxrwxr-x 2 nginx nginx 4096 Aug  5 15:45 05
drwxrwxr-x 2 nginx nginx 4096 Aug  7 11:33 07
drwxrwxr-x 2 nginx nginx   91 Aug 21 17:02 21
drwxrwxr-x 2 nginx nginx  102 Aug 25 14:59 25
drwxrwxr-x 2 nginx nginx  104 Aug 26 16:12 26
[root@04302a060834 08]#

3、得出分析结论:如果 26 的目录是由命令行的 root 用户创建的,那么在基于接口的 nginx 写入文件时,则会报错。如果 26 的目录是由接口的 nginx 用户创建的,那么在基于接口的 nginx 写入文件时,则不会报错。建议写入文件,皆基于命令行的 root 用户来写入。以保证创建目录与写入文件,皆是 root 用户。

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/250552.html

(0)
上一篇 2022年4月29日 23:51
下一篇 2022年4月29日 23:51

相关推荐

发表回复

登录后才能评论