Main Menu

search

You are here

Drupal - create local server

[last updated: 2024-01-21]
Drupal home page
local server Management

obs -local server setup
ddev commands: https://ddev.readthedocs.io/en/latest/users/usage/cli/

composer: https://getcomposer.org/download/
drush releases: https://www.drupal.org/project/drush/releases
use mint or other?:

-----

  • starting over:
    from: https://www.drupal.org/docs/official_docs/local-development-guide
    • I chose to do this install using Docker, DDEV, and ddev composer,
      rather than the option of just using composer.
    • no clue the consequences of this method, just sayin...

    ---------------

    • In the end, I have .../tech/websites/arduinoetal.net/dev-10
      pretty sure the dev-10 is my project name
    • inside the dev-10 folder is a folder named "web"
      I believe this is my "root" directory.

      .../dev-10/dev-10_passwords.txt contains site admin user names and passwords

    ----------------------------------------------------------

  • install Docker
    • Linux installation requires configuring the Docker daemon to start at boot. See Post-installation steps for Linux.
    • On systems without systemd or its equivalent—mostly if you’re installing inside WSL2—you’ll need to manually start Docker with service docker start or the equivalent in your distro. You can add this to your shell profile.
    • docker troubleshooting: https://ddev.readthedocs.io/en/latest/users/install/docker-installation/
    • Don’t sudo with docker or ddev. If you need it, then you haven’t finished the installation.
      Only use sudo with ddev with the ddev hostname command.

    ----------------------------------------------------------

  • install DDEV:
    • Linux requirements:
      RAM: 8GB
    • install DDEV for Linux:
      https://ddev.readthedocs.io/en/latest/users/install/ddev-installation/
      DDEV User Guide: https://ddev.readthedocs.io/en/latest/users/usage/database-management/
      • mkcert:
          "Mkcert is a free, simple, and very useful tool that allows you to create a locally trusted certificate without buying it from the real CA.
          Developers usually work on the local system and it is always impossible to use the trusted certificate from CA on localhost.
          Mkcert allows you to manage your own certificates without any hassle."
          Not sure about this, but best guess so far from surfing/researching is that:
          when a browser loads a website, it looks for a certificate that verifies the validity of the site.
          On a site designed for the public, you can buy a certificate from a Certificate Authority,
          but on a personal, local site with only me as the user, I can self-generate a certificate using mkcert.
      • install mkcert:
        then:
          $ mkcert -install
      • # Add DDEV’s GPG key to your keyring
          $ sudo sh -c 'echo ""'
          $ sudo install -m 0755 -d /etc/apt/keyrings
          $ curl -fsSL https://pkg.ddev.com/apt/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/ddev.gpg > /dev/null
          $ sudo chmod a+r /etc/apt/keyrings/ddev.gpg
      • # Add DDEV releases to your package repository
          $ sudo sh -c 'echo ""'
          $ echo "deb [signed-by=/etc/apt/keyrings/ddev.gpg] https://pkg.ddev.com/apt/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list >/dev/null
      • # Update package information and install DDEV
          $ sudo sh -c 'echo ""'
          $ sudo apt update && sudo apt install -y ddev

    • misc ddev notes:
        "... in DDev ... calling php -v will show the system PHP version outside the container, not inside the DDev container.
        That is why the system is showing 8.2, and while the DDev container, where the webserver lives, is on 8.0.
        Edit /.ddev/config.yml, and change the PHP version to 8.1 or 8.2. Restart DDev and this will install that version of PHP within the container."

    ----------------------------------------------------------

  • Configure local development environment:
        created dev-10 directory (with File Manager) in .../tech/websites/arduinoetal.net folder:
        $ cd ... dev-10

      This will create a new DDEV project configured to host a Drupal application.
      DDEV will store the generated configuration in a new .ddev subdirectory.
      Project name will be the same as the parent folder (my-site), define it with --project-name solrcloud.

    • start the DDEV container:
        $ ddev start
        Lots of stuff downloaded, but no errors...

    • You now have a web server and database server configured and running.
      Configuring DDEV first allows us to run Composer from within DDEV instead of installing it locally.

    ----------------------------------------------------------

  • Create a new Drupal application:
    • use Composer to install Drupal, which enables you to install and update dependencies (modules, themes, profiles, libraries, etc.) also with Composer.
      It is best practice to ensure that your entire Drupal application is managed with Composer in order to facilitate manageable upgrades.
    • create a new Drupal application with Composer.
      Note: ddev composer create will unpack and download the files into the current folder, unlike composer create-project which downloads Drupal into a separate folder.
        $ ddev composer create drupal/recommended-project -y

    • -OR- It is possible to install Drupal with Composer without using the DDEV environment, but not recommended, since PHP versions in DDEV and your local environment may differ.
        $composer create-project drupal/recommended-project
          again lots of stuff downloaded, all finished without error.
          I was in .../tech/websites/arduinoetala.net/dev-10 directory
          New folder created: vendor ("sites" folder had been created earlier with the ... command)
          New files created: composer.json and composer.lock
    • You now have a web server and database server configured and running.

    ----------------------------------------------------------

  • Install Drupal:
    • install Drupal using Drush, which populates your Drupal application’s new database.
      • install the latest version of Drush, a command-line utility for Drupal.
          $ ddev composer require drush/drush
      • Using DDEV and Drush, execute:
          $ ddev drush site:install -y
      • Drupal is now installed, with an automatically generated password for the user #1 account (Administrator).
        User name and password for user #1 can be specified with:
          $ --account-name=myusername --account-pass=my-password.

      ----------------------------------------------------------

    • Launch and log In to new Drupal site:
        • $ ddev launch
      • -OR- generate a one-time login link for the administrator account (user id #1).
          $ ddev drush user:login
      • If necessary, execute:
          $ ddev describe

        to view the URL of your site. Copy and paste that URL into your web browser to visit it.

      ----------------------------------------------------------

    • Next steps:

      ----------------------------------------------------------

    • Misc Notes:
      • "... `composer create-project` requires an absolutely empty directory, with no exceptions.
        So ddev has to build an empty directory before doing `composer create-project`..."

      • ddev phpmyadmin:
        from: https://ddev.readthedocs.io/en/latest/users/usage/database-management/#m...
        "phpMyAdmin, formerly built into DDEV core, can be installed by running:
          $ ddev get ddev/ddev-phpmyadmin

        . "


        Did so, successful. Output:

          Installing project-level components:
          docker-compose.phpmyadmin.yaml
          docker-compose.phpmyadmin-norouter.yaml
          commands/host/phpmyadmin

          Executing post-install actions:
          If router disabled, directly expose port
          You can now use 'ddev phpmyadmin' to launch PhpMyAdmin

          Installed DDEV add-on ddev/ddev-phpmyadmin, use `ddev restart` to enable.
          Please read instructions for this add-on at the source repo at
          https://github.com/ddev/ddev-phpmyadmin
          Please file issues and create pull requests there to improve it.
          Installed phpmyadmin:v0.3.3 from ddev/ddev-phpmyadmin

      ----------------------------------------------------------