AWS Elastic Beanstalk中安装tesseract5.3.4版本

问题

需要在eb(Elastic Beanstalk)的amazon linux 2023中安装tesseract软件。但是,因为amazon linux 2023官方软件库里面没有包含tesseract软件,需要通过开源的Fedora软件源来解决这个问题。

思路

配置Fedora 40软件源(amazon linux 2023的官方文档是说最高兼容Fedora 36,但是这次2025年11月,测试一下Fedora 40软件源中的tesseract5.3.4版本也可以用),然后,使用dnf安装tesseract和中文,英文语言包。

.ebextensions目录结构

bash 复制代码
├── .ebextensions                    
│   ├── 01launch-template.config
│   ├── 02tesseract.config
│   ├── 03timezone.config
│   └── 04environment-variables.config

01launch-template.config

设置应用程序的环境变量。

yaml 复制代码
option_settings:
  aws:elasticbeanstalk:application:environment:
    TESSDATA_PREFIX: /usr/share/tesseract/tessdata
  aws:autoscaling:launchconfiguration:
    DisableIMDSv1: true
    LaunchTemplateTagPropagationEnabled: true

02tesseract.config

这是安装tesseract库。

yaml 复制代码
files:
    "/etc/yum.repos.d/fedora.repo":
        mode: "000644"
        owner: root
        group: root
        content: |
            [fedora]
            name=Fedora 40 - $basearch
            #baseurl=http://download.example/pub/fedora/linux/releases/40/Everything/$basearch/os/
            metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-40&arch=$basearch
            enabled=1
            metadata_expire=7d
            repo_gpgcheck=0
            type=rpm
            gpgcheck=1
            gpgkey=https://src.fedoraproject.org/rpms/fedora-repos/raw/f40/f/RPM-GPG-KEY-fedora-40-primary
            skip_if_unavailable=False

container_commands:
    install_tesseract:
        command: |
            sudo dnf install tesseract -y
            sudo dnf install tesseract-langpack-eng -y
            sudo dnf install tesseract-langpack-chi_sim -y
            sudo dnf install tesseract-langpack-chi_sim_vert -y
        ignoreErrors: true

03timezone.config

这是设置时区。

yaml 复制代码
commands:
    set_timezone:
      command: |
        sudo timedatectl set-timezone Asia/Shanghai
      ignoreErrors: true

04environment-variables.config

设置环境变量

yaml 复制代码
files:
  "/etc/profile.d/environment_variables.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/bin/bash
      export TZ="Asia/Shanghai"
      export TESSDATA_PREFIX="/usr/share/tesseract/tessdata"

container_commands:
    environment_variables:
      command: |
        source /etc/profile
      ignoreErrors: true

总结

这就是eb安装tesseract库和设置时区的过程。执行是按照文件名执行顺序。如果在java中使用Tess4J库通过jni方式调用tesseract,需要注意Tess4J库版本号与tesseract库版本号对应。

参考

相关推荐
pingzhuyan1 小时前
微服务: springboot整合kafka实现消息的简单收发(上)
spring boot·微服务·kafka
sszdlbw2 小时前
后端springboot框架入门学习--第二篇
java·spring boot·学习
阿拉斯攀登2 小时前
MyBatis 全面解析 & Spring Boot 集成实战
java·spring boot·mybatis·持久层框架
qq_12498707532 小时前
基于springboot健康养老APP的设计与实现(源码+论文+部署+安装)
java·spring boot·后端·mysql·微信小程序·毕业设计
Allen正心正念20252 小时前
AWS专家Greg Coquillo提出的8层Agentic AI架构分析
人工智能·架构·aws
老华带你飞7 小时前
健身房预约|基于springboot 健身房预约小程序系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·小程序
paopaokaka_luck7 小时前
基于SpringBoot+Uniapp的自习室预约小程序(腾讯地图API、Echarts图形化分析、二维码识别)
vue.js·spring boot·后端·spring·echarts
q_19132846957 小时前
基于SpringBoot2+Vue2的装修报价网站
java·vue.js·spring boot·mysql·计算机毕业设计·演示文稿
qq_12498707537 小时前
基于Spring Boot的社区医院管理系统的设计与实现(源码+论文+部署+安装)
java·数据库·人工智能·spring boot·毕业设计
阿拉斯攀登7 小时前
MyBatis-Plus 全面介绍 & Spring Boot 集成实战
java·spring boot·mybatisplus·mp