<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andis Kačs</title>
    <description>The latest articles on DEV Community by Andis Kačs (@mnemosx).</description>
    <link>https://dev.to/mnemosx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F658542%2Fe1f3e6b4-ab98-4b51-ab9d-a688002b0497.jpeg</url>
      <title>DEV Community: Andis Kačs</title>
      <link>https://dev.to/mnemosx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mnemosx"/>
    <language>en</language>
    <item>
      <title>Launching Drupal site locally with Docker and ddev</title>
      <dc:creator>Andis Kačs</dc:creator>
      <pubDate>Tue, 29 Jun 2021 15:13:39 +0000</pubDate>
      <link>https://dev.to/mnemosx/launching-drupal-site-locally-with-docker-and-ddev-33dh</link>
      <guid>https://dev.to/mnemosx/launching-drupal-site-locally-with-docker-and-ddev-33dh</guid>
      <description>&lt;p&gt;After spending waay too much time trying to set up a local nginx web server for an existing Drupal site on Mac, I just had to give up. According to every tutorial on the web it was supposed to be a simple few-step process, however in reality it seemed impossible to configure all the necessary parts to work together.&lt;/p&gt;

&lt;p&gt;I'm still not completely sure if the culprit was nginx's r/w/x permissions that I may have not set correctly, or some part of the nginx conf file that I also may have not set up correctly, or, perhaps, Drupal wasn't connecting to the database, or, maybe, it was the php-fpm that was playing a crucial part in the whole setup, but, again, needed to be configured correctly. &lt;/p&gt;

&lt;p&gt;The point is, there's too much stuff for a developer to configure. Especially, for a front-end dev such as myself who's used to just typing in a console &lt;code&gt;npm install&lt;/code&gt; and &lt;code&gt;npm run start&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Luckily, ddev comes to aid.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;There's a wide variety of tools designed to simplify local development environments for Drupal. In fact, many of them are listed in &lt;a href="https://www.drupal.org/docs/develop/local-server-setup/docker-development-environments/docker-solutions-overview"&gt;Drupal docs&lt;/a&gt;. In hopes for better performance, I went with &lt;strong&gt;&lt;a href="https://ddev.readthedocs.io/en/stable/"&gt;ddev&lt;/a&gt;&lt;/strong&gt; because of their support for M1 Macs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Apple Silicon M1 (ARM64) is supported in v1.17-alpha1+ (edge versions).  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To install ddev using Homebrew, use command &lt;code&gt;brew install drud/ddev-edge/ddev&lt;/code&gt; or &lt;code&gt;brew install drud/ddev/ddev&lt;/code&gt; for a stable version.&lt;/p&gt;

&lt;p&gt;Of course, your system also needs Docker to be installed. See &lt;a href="https://ddev.readthedocs.io/en/stable/users/docker_installation/"&gt;ddev docs for docker installation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;So, let's say you are given a repo that contains a Drupal project along with all the site files. Naturally, the first thing you do is clone the project using &lt;code&gt;git clone https://github.com/example/example-site&lt;/code&gt; and cd into it &lt;code&gt;cd example-site&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, ddev comes to play. Before you can execute any ddev commands, you need to run &lt;code&gt;ddev config&lt;/code&gt;. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; All ddev commands need to be launched from the project root folder!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It will walk you through some basic config steps such as project name and project type, but since ddev seems to be pretty good at guessing the appropriate values, I didn't even need to type in anything.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ddev.readthedocs.io/en/stable/users/cli-usage/"&gt;The docs&lt;/a&gt; contain quick start guides for all kinds of setups; I was interested in Drupal 9 section and much to my surprise (and relief) there are only two commands to run: &lt;code&gt;ddev composer install&lt;/code&gt; and &lt;code&gt;ddev launch&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; If you haven't run the &lt;code&gt;mkcert -install&lt;/code&gt; command before, now is the time. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If everything runs smoothly, ddev will output a message saying &lt;code&gt;Project can be reached at https://yourprojectname.ddev.site https://127.0.0.1:64124&lt;/code&gt;. But before accessing your site, a database needs to be added. In my case, I was provided with a raw SQL dump in a form of a .sql file which I could easily add to the project using &lt;code&gt;ddev import-db --src=/path/to/file/db.sql&lt;/code&gt;. Another thing to note - since the project I cloned was previously configured manually, there was a databases configuration left in &lt;code&gt;sites/default/settings.php&lt;/code&gt; which needed to be removed since ddev created its own databases config in &lt;code&gt;settings.ddev.php&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And that's it.&lt;/p&gt;

&lt;p&gt;It also automatically set up &lt;em&gt;phpmyadmin&lt;/em&gt; for us. You can check the port number for it (among other useful stuff) by executing &lt;code&gt;ddev describe&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  To recap
&lt;/h2&gt;

&lt;p&gt;Step 1 - Install Docker&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install homebrew/cask/docker
// or visit
https://docs.docker.com/docker-for-mac/install/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2 - Install ddev&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install drud/ddev-edge/ddev
// or
brew install drud/ddev/ddev 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3 - Get your project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/example/example-site &amp;amp;&amp;amp; cd example-site
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4 - Config ddev for your project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ddev config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 5 - Install project dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ddev composer install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 6 - Import database&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ddev import-db --src=/path/to/file/db.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ddev launch&lt;/code&gt; and done!&lt;/p&gt;

</description>
      <category>drupal</category>
      <category>docker</category>
      <category>ddev</category>
      <category>nginx</category>
    </item>
  </channel>
</rss>
