简体   繁体   English

如何使用 docker 和 ddev 设置 TYPO3 站点?

[英]How to set up a TYPO3 site with docker and ddev?

I'm new to docker and I've been told ddev is a simple way to set up a local container to run a TYPO3 project.我是docker 新手,有人告诉我ddev是一种设置本地容器来运行 TYPO3 项目的简单方法。

But I'm confused.但我很困惑。 I'm not familiar with all these containers yet.我还不熟悉所有这些容器。 How should I proceed to get a grip?我应该如何进行抓握?

The tutorial is based on https://docs.typo3.org/m/typo3/guide-contributionworkflow/master/en-us/Appendix/SettingUpTypo3Ddev.html but mind – that is a step-by-step-manual if you want to contribute to the TYPO3 core.本教程基于https://docs.typo3.org/m/typo3/guide-contributionworkflow/master/en-us/Appendix/SettingUpTypo3Ddev.html但请注意 - 如果您愿意,这是一个分步手册为TYPO3核心做出贡献。 If you want to run your own site, the «Clone TYPO3» section doesn't apply.如果您想运行自己的站点,则《克隆 TYPO3》部分不适用。

So start like this:所以开始这样:

  1. Install Docker (Desktop App is fine) from https://www.docker.com/products/docker-desktophttps://www.docker.com/products/docker-desktop安装 Docker(桌面应用程序很好)
  2. Install ddev: https://ddev.readthedocs.io/en/latest/#installation (Mac: brew tap drud/ddev && brew install ddev )安装 ddev: https://ddev.readthedocs.io/en/latest/#installation (Mac: brew tap drud/ddev && brew install ddev )
  3. Create a directory where you want to run the site: mkdir mysite; cd mysite创建一个要运行站点的目录: mkdir mysite; cd mysite mkdir mysite; cd mysite
  4. Configure ddev: run ddev config There's not much to choose from in the wizard.配置 ddev:运行ddev config向导中没有太多可供选择的内容。 You can set the web-root (eg. public_html, so you have a level more above) and choose from a few CMS presets.您可以设置 web 根目录(例如 public_html,因此您有更高的级别)并从几个 CMS 预设中进行选择。 They don't change too much, in the case of TYPO3 it will manage the db connection and some nginx settings.他们不会改变太多,在 TYPO3 的情况下,它将管理数据库连接和一些 nginx 设置。 The file .ddev/config.yaml will be created.将创建文件 .ddev/config.yaml。 In it you can find a lot of options.您可以在其中找到很多选项。
  5. Add your site (and, if necessary, run composer)添加您的站点(并在必要时运行 Composer)
  6. Run ddev with ddev start使用ddev start运行 ddev
  7. See if mkcert is installed, if not, follow the provided instructions (this will make sure you can use self-signed certificates, at least in firefox) (mac: brew install mkcert nss; mkcert -install )查看是否安装了 mkcert,如果没有,请按照提供的说明进行操作(这将确保您可以使用自签名证书,至少在 firefox 中)(mac: brew install mkcert nss; mkcert -install
  8. ddev will output a few informations, where you can find your site, which port, where phpmyadmin is etc ddev 会输出一些信息,你可以在哪里找到你的站点,哪个端口,phpmyadmin 在哪里等
  9. ddev help gives you more commands ddev help为您提供更多命令
  10. If you want to log into the container, use ddev ssh .如果要登录容器,请使用ddev ssh This is NOT used to change files etc. The files are mirrored automatically into the container!这不用于更改文件等。文件会自动镜像到容器中! But you can log in to install binaries etc. Let's try that.但是您可以登录以安装二进制文件等。让我们尝试一下。 Some commands you may need: What system are we running?您可能需要的一些命令: 我们正在运行什么系统? uname -a -> linuxkit // Update available packages: sudo apt-get update // Search for a package apt-cache search packagename // Install Pdftools (pdftotext, pdfinfo..): sudo apt-get install poppler-utils // Get the path to imagemagick (if it's already installed): whereis convert (remember, imagemagick is a collection, convert is one of the tools) // log out from the container, back to your system: exit uname -a -> linuxkit // 更新可用包: sudo apt-get update // 搜索包apt-cache search packagename // 安装 Pdftools (pdftotext, pdfinfo..): sudo apt-get install poppler-utils //获取imagemagick的路径(如果已经安装了): whereis convert (记住,imagemagick是一个集合,convert是工具之一)//退出容器,回到你的系统: exit
  11. Now, how to connect to the database which lives inside the docker container?现在,如何连接到位于 docker 容器内的数据库? run ddev describe and you will get the login data.运行ddev describe ,您将获得登录数据。 It's basically db for everything.它基本上是db的一切。
  12. For TYPO3, the ddev setup command provides an AdditionalConfiguration.php file that can be used.对于TYPO3, ddev setup命令提供了一个可以使用的AdditionalConfiguration.php文件。 It's missing two important parameters though, SystemMaintainers and Installtool Password.但是它缺少两个重要参数,SystemMaintainers 和 Installtool Password。 Here's an example.这是一个例子。
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'], [
                    'dbname' => 'db',
                    'host' => 'db',
                    'password' => 'db',
                    'port' => '3306',
                    'user' => 'db',
]);

// This mail configuration sends all emails to mailhog
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport'] = 'smtp';
$GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_smtp_server'] = 'localhost:1025';

$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'] = '*';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors'] = 1;

// add these
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemMaintainers'] = [123,456];
$GLOBALS['TYPO3_CONF_VARS']['BE']['lockSSL'] = 1; // optional
$GLOBALS['TYPO3_CONF_VARS']['BE']['installToolPassword'] = '123';
  1. But what if you want to access the database with a separate tool instead of the preconfigured phpMyAdmin?但是,如果您想使用单独的工具而不是预配置的 phpMyAdmin 访问数据库,该怎么办? If you use sequel pro, simply run ddev sequelpro and your database will be launched automagically in sequel pro.如果您使用 sequel pro,只需运行ddev sequelpro ,您的数据库将在 sequel pro 中自动启动。 You can also do this manually;您也可以手动执行此操作; then you need to define the db port to access it externally.那么您需要定义数据库端口以从外部访问它。 Do this in .ddev/config.yaml, by adding (for example) host_db_port: "32778" Now we can set up a db management tool as such (and store the bookmark):在 .ddev/config.yaml 中执行此操作,通过添加(例如) host_db_port: "32778"现在我们可以这样设置数据库管理工具(并存储书签):

使用 sequel pro 连接到 ddev mysql

Remember: PHP will still use the default Port 3306!请记住:PHP 仍将使用默认端口 3306!

  1. Ok, here we go.好的,我们开始。 ddev is already started, so make sure you're in your local directory (where .ddev/ is) and run ddev describe to see the parameters again. ddev 已启动,因此请确保您位于本地目录(.ddev/ 所在的位置)并运行 ddev describe 以再次查看参数。 Probably, if you go to https://mysite.ddev.local , you will find everything from your webroot working.可能,如果你去https://mysite.ddev.local ,你会发现你的 webroot 中的所有东西都在工作。
  2. When done, finish with ddev stop .完成后,以ddev stop结束。 I'm not really sure where databases are persisted though yet, when ddev is stopped.当 ddev 停止时,我还不确定数据库在哪里持久化。 Maybe you get a dump first with ddev snapshot .也许您首先使用ddev snapshot进行转储。
  3. Explore many more possibilities of ddev with ddev help .使用ddev help探索 ddev 的更多可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM