error:
Access to the path '/var/www/bin/release/net5.0/publish/wwwroot/uploadimages/cplusplustimeline.png' is denied
/Blog/edit/Access to the path '/Nop.Web/bin/release/netcoreapp3.0/publish/wwwroot/uploadimages/20191218233033hkping.png' is denied.
reason:
Linux's permissions system is very different from that of Windows。
slove:
chmod -R 777 tmp
chmod -R 777 ./src/Presentation/Nop.Web/bin/release/net5.0/publish/wwwroot
Linux/Unix 是多人多工作业系统,所有的档案皆有拥有者。利用 chown 可以将档案的拥有者加以改变。
这个指令只有是由系统管理者(root)所使用,一般使用者没有权限可以改变别人的档案拥有者,也没有权限可以自己的档案拥有者改设为别人。只有系统管理者(root)才有这样的权限。
ls -l
档案类型‘d’:表示文件夹,‘-’:表示文件
chown
改变拥有者和群组
chmod
Linux/Unix 的档案调用权限分为三级 : 档案拥有者、群组、其他。利用 chmod 可以藉以控制档案如何被他人所调用
语法为:chmod abc file
其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。
r=4,w=2,x=1
若要rwx属性则4+2+1=7;
若要rw-属性则4+2=6;
若要r-x属性则4+1=5。
chmod -R 777 /tmp
-R 是指级联应用到目录里的所有子目录和文件
777 是所有用户都拥有最高权限
Nopcommerce 4.x 发布到Linux后运行出现错误:
An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information.
ystem.Security.Cryptography.CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. ---> System.UnauthorizedAccessException: Access to the path '/var/www/aspnetcore46/Grand.Web/bin/release/netcoreapp3.1/publish/App_Data/DataProtectionKeys/5c38e39f-ce45-4a26-acd8-1a5f0092d906.tmp' is denied. ---> System.IO.IOException: Permission denied --- End of inner exception stack trace --- at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.StoreElementCore(XElement element, String filename) at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.StoreElement(XElement element, String friendlyName) at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.IInternalXmlKeyManager.CreateNewKey(Guid keyId, DateTimeOffset creationDate, DateTimeOffset activationDate, DateTimeOffset expirationDate) at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.CreateNewKey(DateTimeOffset activationDate, DateTimeOffset expirationDate) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext) --- End of inner exception stack trace --- at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext) at Microsoft.AspNetCore.Session.CookieProtection.Protect(IDataProtector protector, String data) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Grand.Framework.Middleware.InstallUrlMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper) in /var/www/msly/mslyaspnetcoregrandnode46/Grand.Framework/Middleware/InstallUrlMiddleware.cs:line 50 at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
bin/release/netcoreapp3.1/publish/App_Data/DataProtectionKeys目录没有读写权限
chmod -R 777 DataProtectionKeys