如何通过 docker compose yml 在 vps 服务器上设置 pimcore

如何通过 docker compose yml 在 vps 服务器上设置 pimcore

我真的筋疲力尽,无法在我的 vps 服务器上运行 pimcore。

我尝试了几个操作系统,例如 Unbuntu 18 / 20 或 CentOS 7。我尝试通过 composer 安装 pimcore。但我总是会遇到一些错误,当我尝试修复它们时,它们又会导致更多错误。

对我来说最好的方法是使用 docker-compose.yml。我设法用它安装了 pimcore,并且能够运行此处描述的容器:https://github.com/pimcore/skeleton/tree/10.2

安装 pimcore 后,我将 vhost 指向 my-project/public。有 index.php 现在我收到此错误

驱动程序中发生异常:SQLSTATE[HY000] [2002] php_network_getaddresses:db 的 getaddrinfo 失败:名称或服务未知

我确实尝试在 docker-compose.yml 和 .env 文件中设置数据库主机。但仍然没有用。

现在我停止了容器,并惊讶地发现,即使没有运行容器,我的域中错误仍然存​​在。

我是否需要告诉我的 VPS 它必须使用 docker-compose.yml 数据库?或者我还需要做其他什么事情才能通过 docker-compose 在我的服务器上运行 pimcore?我只是使用了 pimcore/github 提供的骨架版本。

我真的需要你的帮助。

这是我的docker-compose.yml:

services:
    redis:
        image: redis:alpine
        command: [ redis-server, --maxmemory 128mb, --maxmemory-policy volatile-lru, --save "" ]

    db:
        image: mariadb:10.7
        working_dir: /application
        command: [mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_unicode_ci, --innodb-file-per-table=1]
        volumes:
            - pimcore-database:/var/lib/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=ROOT
            - MYSQL_DATABASE=db
            - MYSQL_USER=user
            - MYSQL_PASSWORD=pw

    nginx:
        image: nginx:stable-alpine
        ports:
            - "80:80"
        volumes:
            - .:/var/www/html:ro
            - ./.docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
        depends_on:
            - php

    php:
        user: '1000:1000' # set to your uid:gid
        image: pimcore/pimcore:php8.1-debug-latest
        environment:
            COMPOSER_HOME: /var/www/html
            PHP_IDE_CONFIG: serverName=localhost
        depends_on:
            - db
        volumes:
            - .:/var/www/html

    supervisord:
        user: '1000:1000' # set to your uid:gid
        image: pimcore/pimcore:php8.1-supervisord-latest
        depends_on:
            - db
        volumes:
            - .:/var/www/html
            - ./.docker/supervisord.conf:/etc/supervisor/conf.d/pimcore.conf:ro

volumes:
    pimcore-database:

这是我的 config/config.yaml:

imports:
    - { resource: 'local/' }


pimcore:

# IMPORTANT Notice!
# Following there are only some examples listed, for a full list of possible options, please run the following command:
# ./bin/console debug:config pimcore
# you can also filter them by path, eg.
# ./bin/console debug:config pimcore assets
# or even more specific:
# ./bin/console debug:config pimcore assets.image


#### TRANSLATIONS
#    translations:
#        case_insensitive: true

#### FEATURE FLAGS
#    flags:
#        zend_date: true

#### CLASS OVERRIDES EXAMPLES
#    models:
#        class_overrides:
#            'Pimcore\Model\DataObject\News': 'App\Model\DataObject\News'
#            'Pimcore\Model\DataObject\News\Listing': 'App\Model\DataObject\News\Listing'
#            'Pimcore\Model\DataObject\Folder': 'App\Model\DataObject\Folder'
#            'Pimcore\Model\Asset\Folder': 'App\Model\Asset\Folder'
#            'Pimcore\Model\Asset\Image': 'App\Model\Asset\Image'
#            'Pimcore\Model\Document\Page': 'App\Model\Document\Page'
#            'Pimcore\Model\Document\Link': 'App\Model\Document\Link'
#            'Pimcore\Model\Document\Listing': 'App\Model\Document\Listing'


#### CUSTOM DOCUMENT EDITABLES
#    documents:
#        allow_trailing_slash: 'yes'
#        generate_preview: false
#        tags:
#            map:
#                markdown: \App\Model\Document\Tag\Markdown


#### CUSTOM OBJECT DATA TYPES
#    objects:
#        class_definitions:
#            data:
#                map:
#                  myDataType: \App\Model\DataObject\Data\MyDataType


#### ASSET CUSTOM SETTINGS
#    assets:
#        icc_rgb_profile: ''
#        icc_cmyk_profile: ''
#        versions:
#            use_hardlinks: false
#        image:
#            low_quality_image_preview:
#                enabled: false
#                generator: imagick
#            thumbnails:
#                webp_auto_support: false


#### SYSTEM SETTINGS

#    general:
#        timezone: Europe/Berlin
#        path_variable: ''
#        instance_identifier: ''
#    services:
#        google:
#            client_id: 738936983.apps.googleusercontent.com
#            email: [email protected]
#            simple_api_key: AIzaSyCo9Wj49hW2WgOju4iMYNTvdcBxmyQ8
#            browser_api_key: AIzaSyBJX16kWAmU1amzp2iKqAfumbcoQQ
#    full_page_cache:
#        enabled: false
#        lifetime: null
#        exclude_cookie: ''
#        exclude_patterns: ''
#    httpclient:
#        adapter: Socket # use 'Proxy' for custom proxy configuration
#        proxy_host: ''
#        proxy_port: ''
#        proxy_user: ''
#        proxy_pass: ''
#    email:
#        sender:
#            name: 'Pimcore Demo'
#            email: [email protected]
#        return:
#            name: ''
#            email: ''
#    newsletter:
#        use_specific: false # set true to use the following options for newsletter delivery
#        sender:
#            name: ''
#            email: ''
#        return:
#            name: ''
#            email: ''

#    applicationlog:
#        mail_notification:
#            send_log_summary: false
#            filter_priority: null
#            mail_receiver: ''
#        archive_treshold: '30'
#        archive_alternative_database: ''

#### SYMFONY OVERRIDES
framework:

#### DEFINE LOCATION OF MANIFEST WHEN WORKING WITH SYMFONY ENCORE
#    assets:
#        json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'

#### USE CUSTOM CACHE POOL
#    cache:
#        pools:
#            pimcore.cache.pool:
#                public: true
#                tags: true
#                default_lifetime: 31536000  # 1 year
#                adapter: pimcore.cache.adapter.redis_tag_aware
#                provider: 'redis://localhost' # Redis DNS, see: https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html#configure-the-connection

#### USE SESSION HANDLER CONFIGURED IN php.ini
#    session:
#        handler_id: null

#### SYMFONY MAILER TRANSPORTS
#    mailer:
#        transports:
#            main: smtp://user:[email protected]:port
#            pimcore_newsletter: smtp://user:[email protected]:port

它在 config/local/database.yaml 中吗?

# imports:
#     - { resource: 'local/' }

parameters:
    database_host: 'pimcoredb'
    database_port: 3306
    database_name: 'db'
    database_user: 'user'
    database_password: 'pw'

pimcore:

答案1

您的数据库容器被称为db,但您配置了 pimcore 来连接到名为 的主机pimcoredb

更改您的数据库配置来连接db

parameters:
  database_host: 'db'

相关内容