简体   繁体   中英

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.

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. If you want to run your own site, the «Clone TYPO3» section doesn't apply.

So start like this:

  1. Install Docker (Desktop App is fine) from https://www.docker.com/products/docker-desktop
  2. Install 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
  4. Configure ddev: run ddev config There's not much to choose from in the wizard. You can set the web-root (eg. public_html, so you have a level more above) and choose from a few CMS presets. They don't change too much, in the case of TYPO3 it will manage the db connection and some nginx settings. The file .ddev/config.yaml will be created. In it you can find a lot of options.
  5. Add your site (and, if necessary, run composer)
  6. Run ddev with ddev start
  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 )
  8. ddev will output a few informations, where you can find your site, which port, where phpmyadmin is etc
  9. ddev help gives you more commands
  10. If you want to log into the container, use 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
  11. Now, how to connect to the database which lives inside the docker container? run ddev describe and you will get the login data. It's basically db for everything.
  12. For TYPO3, the ddev setup command provides an AdditionalConfiguration.php file that can be used. It's missing two important parameters though, SystemMaintainers and 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? If you use sequel pro, simply run ddev sequelpro and your database will be launched automagically in 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):

使用 sequel pro 连接到 ddev mysql

Remember: PHP will still use the default Port 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. Probably, if you go to https://mysite.ddev.local , you will find everything from your webroot working.
  2. When done, finish with ddev stop . I'm not really sure where databases are persisted though yet, when ddev is stopped. Maybe you get a dump first with ddev snapshot .
  3. Explore many more possibilities of ddev with ddev help .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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