You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Ubuntu22.04部署NopCommerce遇权限异常问题求助

NopCommerce 4.60.3 Ubuntu 22.04 部署权限问题排查

问题场景

环境:Microsoft Azure云 Ubuntu 22.04,已安装HestiaCP控制面板,通过Hestia-NetCore模板配置.NET Core环境,示例应用运行正常。
操作:下载NopCommerce 4.60.3 Linux无源码版,解压至指定目录,配置服务以dotnet Nop.Web.dll启动。
报错:浏览器访问时抛出UnauthorizedAccessException,具体信息如下:

IOException: Permission denied
Unknown location
UnauthorizedAccessException: Access to the path '/home/test/web/store/netcoreapp/App_Data/DataProtectionKeys/key-acc685fa-d997-4794-9290-438a3e5c3e8d.xml' is denied.
Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, string path, bool isDirError)
CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning
Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(byte[] plaintext)

问题解答

1. 需要设置写入权限的文件夹

  • App_Data 目录及其所有子目录:包含DataProtectionKeys(存储数据加密密钥)、Logs(运行日志)、Plugins(插件文件)、TempUploads(临时上传文件)等核心存储目录
  • wwwroot/content、wwwroot/images:用于存储静态资源、用户上传的商品图片等内容

2. 正确的权限设置方案

首先确认运行NopCommerce的进程用户:HestiaCP环境中,.NET Core应用通常由www-data用户或网站专属用户(如示例中的test)运行,可通过以下命令查看:

ps aux | grep dotnet

根据进程用户执行以下权限调整命令:

  1. 递归设置目录所有者为运行进程的用户和www-data组(以www-data:www-data为例,若为网站专属用户则替换为test:www-data):
    sudo chown -R www-data:www-data /home/test/web/store/netcoreapp
    
  2. 递归设置基础权限:目录755(可读可写可执行),文件644(可读可写):
    sudo find /home/test/web/store/netcoreapp -type d -exec chmod 755 {} \;
    sudo find /home/test/web/store/netcoreapp -type f -exec chmod 644 {} \;
    
  3. 对需要写入的核心目录追加权限:
    sudo chmod -R 775 /home/test/web/store/netcoreapp/App_Data
    sudo chmod -R 775 /home/test/web/store/netcoreapp/wwwroot/content
    sudo chmod -R 775 /home/test/web/store/netcoreapp/wwwroot/images
    

当前设置azureuser:www-data报错,说明运行进程的用户并非azureuser,需根据实际进程用户调整所有者配置。

内容的提问来源于stack exchange,提问作者yvijay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 22:52:38