Post

Install Drupal

Install Drupal on Digital Ocean

Digital Ocean has a OpenLiteSpeed droplet for Drupal which has

  • Composer
  • Drush
  • PHP 8.1
  • Configured to serve the web directory

Using Drush to Login

1
vendor/bin/drush uli --uri http://your-site-url

Ensure to add your domain to Digital Ocean before you do the following config. Once you have installed your droplet, open the console from Digital Ocean admin.

  • The first question to answer is “what is your domain”.
  • The second question is do you want an ssl

Its harder to configure this stuff later, so best get it right from the start.

Or you can just work from an ip address as the site is accessible from the ip address

Add the droplet and follow the prompts to add

  • Your ssh key
  • Your domain
  • SSL certificate

At this point you should be able to access the drupal welcome screen.

Install your apps

  • Use scp to copy your composer.json file to your server to your project root
  • Run composer install in the root.

Import database

  • Activate the backup and migrate plugin and import your database

Install your theme

  • Locally zip your web/themes/custom theme folder
  • Use scp to deploy your custom.zip to the server
  • Use unzip to unzip your custom.zip
  • Clear the cache and reload you, you should be able to see your theme loading.

Deploy files

If you see stylesheet is missing from your drupal site. You just need to deploy the files directory as we do not keep it under version control.

use scp to deploy web/sites/default/files

best to zip first.

1
zip files.zip -r files
1
scp files.zip  your_server:/var/www/html/web/sites/default/

Install Drupal Locally

There are various ways to install Drupal locally. Below are some of the ways I have installed Drupal locally in the past.

Set Up a Drupal Site Locally with DDEV:

  1. Create a New Drupal Project:
    • Open your terminal/command prompt.
    • Navigate to the directory where you want to create your Drupal project.
    • Run the following commands:
1
2
3
cd your/drupal/project-dir
ddev config --project-type=drupal10
ddev composer create "drupal/recommended-project:^10"

Set PHP version

Edit .ddev/config.yaml

1
2
3
4
5
6
7
8
9
10
11
12
name: my-drupal-project
type: drupal9
docroot: web
php_version: "8.0"
webserver_type: apache-fpm
database:
  type: mariadb
  version: "10.3"
router_http_port: "8080"
router_https_port: "8443"
additional_flexible_config: false

Start DDev

Ensure your containers in Docker Desktop are running.

1
ddev start

Troubleshooting

If you get error “Could not connect to a Docker provider. Please start or install a Docker provider. For install help go to: https://ddev.readthedocs.io/en/latest/users/install/”

open docker-desktop and hit the start button then run below command again.

1
ddev config --project-type=drupal10

Fix can’t listen on port 80

Failed to start sitename: unable to listen on required ports, port 443 is already in use,

1
ddev poweroff && docker rm -f $(docker ps -aq)
1
ddev start
  1. Stop other services using the port. For instance:
1
valet stop

Now start DDev again.

1
ddev start
  1. Stop all docker containers and Restart docker
1
ddev poweroff && docker rm -f $(docker ps -aq)

Edit Docroot

Fix the error 403 Forbidden when you visit your ddev site. Update .ddev/config with a relative path to drupals root index.php.

1
vim .ddev/config.yml
1
docroot: "web"

After updating config file DDev. Ensure you have an index.php inside the web directory fixing these to issues, This will fix any 403 permission issues.

DDev important note.

Ddev drupal usage changes a little. ie:

To install module using ddev

1
ddev composer require drupal/devel

Install Drush with DDev

1
ddev composer require drush/drush

Install Drupal:

  • Access the Drupal site in your browser. The URL will typically be http://.ddev.site.
  • Follow the Drupal installation wizard:
  • Choose a language.
  • Select the installation profile (Standard is typical).
  • Enter database connection details (use db for the database host).
  • Continue with the installation process.

Configure Site:

  • After installation, you’ll be prompted to configure your Drupal site.
  • Set up the site name, admin username, password, and other settings.

Stop DDEV:

1
When you're done working on your Drupal site, you can stop the DDEV environment:
1
ddev stop

2. Install Drupal Locally using Valet

Valet comes from the Laravel world. It’s a step up from using mamp/xammp. The difference between valet and mamp is with Valet there is no UI. You run commands on the command line to start and stop valet services such as MySQL and PHP and create local website instances.

Prerequisites

  • Valet installed locally
  • Composer installed

Steps to install Drupal locally

3. Install quick start Drupal

Prerequisites

  • Composer installed

Quick start drupal is good for quick experiments it’s not recommended to use for a production build. but if you’re looking to get a quick local off the ground just to try out a plug-in or test a vanilla install it’s good for that.

Install Quick-Start Drupal locally with Composer

Running the below command will create a drupal play ground.

  • Start a local site on http://127.0.0.1:8888/
  • Install the latest version of drupal
  • Using sqlite db
  • Install the demo_uami food magazine theme
  • The admin login details will be output in the commandline for you
1
2
composer create-project drupal/recommended-project drupal
cd drupal && php -d memory_limit=256M web/core/scripts/drupal quick-start demo_umami

Restart the quick-start site

After you close it (Ctrl-C) and you want to start it again

1
php -d memory_limit=256M web/core/scripts/drupal quick-start

More information

drupal download drupal install

This post is licensed under CC BY 4.0 by the author.