CentOs8安装redis与Linux安装GDI+图形

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", "<你的入口程序集>"]

 

posted @ 2020-11-29 12:56  netlock  阅读(942)  评论(0编辑  收藏  举报