1、安裝
yum install redis
2、編輯配置文件
vim /etc/redis.conf #requirepass那行並打開注釋,在后面寫自己的密碼,如下 requirepass yourpassword 將bind 后 127.0.0.1 改為 內網IP # 為安全起見,請勿使用 0.0.0.0 protected-mode yes 改為 protected-mode no # 關閉保護模式 daemonize no 改為 daemonize yes # 開啟守護進程
3、啟動
systemctl start redis //重啟 systemctl stop redis
4、開啟自啟動
systemctl enable redis
5、開放防火牆端口(如有需要)
firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=6379/tcp --permanent //重啟防火牆 systemctl restart firewalld
.net core GUI+庫 在linux發布的坑
微軟官方提供了一個組件 System.Drawing.Common
實現生成驗證碼、二維碼,QRCoder是一個非常強大的生成二維碼的組件,它使用了 System.Drawing.Common
在Windows沒問題 發布到linux生成就會出現
該異常的意思是: 找不到DLL libgdiplus
System.Drawing.Common 組件提供對GDI+圖形功能的訪問。它是依賴於GDI+的,那么在Linux上它如何使用GDI+,因為Linux上是沒有GDI+的。Mono 團隊使用C語言實現了GDI+接口,提供對非Windows系統的GDI+接口訪問能力(個人認為是模擬GDI+,與系統圖像接口對接),這個就是 libgdiplus。進而可以推測 System.Drawing.Common 這個組件實現時,對於非Windows系統肯定依賴了 ligdiplus 這個組件。如果我們當前系統不存在這個組件,那么自然會報錯,找不到它,安裝它即可解決。
libgdiplus github: https://github.com/mono/libgdiplus
1.CentOS
#一鍵命令 sudo curl https://raw.githubusercontent.com/stulzq/awesome-dotnetcore-image/master/install/centos7.sh|sh
或者
yum update yum install libgdiplus-devel -y ln -s /usr/lib64/libgdiplus.so /usr/lib/gdiplus.dll ln -s /usr/lib64/libgdiplus.so /usr/lib64/gdiplus.dll
2.Ubuntu
#一鍵命令 sudo curl https://raw.githubusercontent.com/stulzq/awesome-dotnetcore-image/master/install/ubuntu.sh|sh
或者
apt-get update apt-get install libgdiplus -y ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
3.Docker
Dockerfile 加入 RUN 命令,以官方 asp.net core runtime 鏡像,以 asp.net core 2.2 作為示例:
FROM microsoft/dotnet:2.2.0-aspnetcore-runtime WORKDIR /app COPY . . RUN apt-get update -y && apt-get install -y libgdiplus && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll EXPOSE 80 ENTRYPOINT ["dotnet", "<你的入口程序集>"]
apt-get update 這一步是必不可少的,不然會報找不到 libgdiplus。但是官方鏡像里面使用的軟件包源又是國外的地址,所以造成我們使用國內網絡非常慢,進而造成整體構建過程非常慢。下面有兩個解決方案:
直接使用打包好的Docker鏡像
該鏡像是基於微軟官方鏡像打包的,只安裝了 libgdiplus,不添加任何添加劑。
將 Dockerfile 中的 FROM microsoft/dotnet:2.2.0-aspnetcore-runtime 換為 FROM stulzq/dotnet:2.2.0-aspnetcore-runtime-with-image
示例:
FROM stulzq/dotnet:2.2.0-aspnetcore-runtime-with-image WORKDIR /app COPY . . EXPOSE 80 ENTRYPOINT ["dotnet", "<你的入口程序集>"]