Install and configure a Drupal 10 website on DreamHost using Composer

The goal of this tutorial is to demonstrate how to install a Drupal 10 site on DreamHost using composer and Drush.

Create a new Domain/Subdomain

Login to your DreamHost account and navigate to “Websites” -> “Manage Websites” and click the “+ Add Website” button:

Navigate to “Websites” -> “Manage Websites” and click the “+ Add Website” button:

Choose a Domain for your new Drupal site. You have the following options to assign a Domain to your new Drupal site: 

  • Enter a domain or subdomain you already own
  • Create a subdomain
  • Register a new domain

For this tutorial, I will create a new subdomain for my Drupal site:

Create a subdomain

On the “Create a subdomain” page, assign a name for the subdomain and select the parent domain. Click the “Next: Hosting” button to continue:

Creating a new subdomain

On the “Connect this domain to a hosting plan” page, I selected the “Shared Unlimited” option and then I clicked the “Set Up Website” button. I have the “Shared Unlimited” hosting plan with offers unlimited websites and free SSL certificates.

Connecting your new domain/subdomain to a hosting plan.

Wait until the process is complete:

Wait until the process is complete

Add an SSL Certificate to your Domain/Subdomain

Once the website setup is completed, click the “•••” button next to your new subdomain/domain to show more options and then click the “SSL Security” link:

Add an SSL Certificate to your Domain/Subdomain.

On the next page, under the Free Let’s Encrypt SSL Certificate option, click the “Select this Certificate” button:

Let’s Encrypt SSL Certificate

Wait until the new certificate for your new subdomain/domain is complete. With this SSL Certificate, the traffic to your site will automatically get redirected to your site over a secure HTTPS connection. You should see this reflected on your website within 15 minutes.

Changing your domain’s username (Optional)

  1. Navigate to the Manage Websites page.
  2. Click the Manage button to open the Manage Websites page, which allows you to adjust various settings for your site.
    • If in Grid view, click the Manage button at the bottom of the website box.
    • If in List view, click the Manage button at the far right of your domain name.
  3. Click the Login Info button under Manage Your Site.
  4. Click the Switch user button.
Changing your domain's username.

Select the user you want to control this domain from the dropdown and click the “Save user” button:

Select the user you want to control this domain from the dropdown.

Wait until the process is complete:

Switching username.

Change the PHP version the shell uses

Make sure you’re in your user’s directory by running the following:

cd ~

Edit the .bash_profile file:

nano .bash_profile

Add the following line to force PHP 8.1:

export PATH=/usr/local/php81/bin:$PATH

Save and close the file and return to your shell.

Update that file by running the following command:

. ~/.bash_profile

If you now run php -v you’ll see the new version being used:

php -v
PHP 8.1.17 (cli) (built: Apr 12 2023 20:44:31) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.17, Copyright (c) Zend Technologies
	with Zend OPcache v8.1.17, Copyright (c), by Zend Technologies

Install Composer Globally

Login to your server via SSH and Navigate to your user’s home directory:

cd ~

Make a directory for installation. You can choose any valid directory name, but these instructions will assume the directory ~/.php/composer:

mkdir -p ~/.php/composer

Navigate to the installation directory:

cd ~/.php/composer

Run the Composer installer:

curl -sS | php

Edit your existing .bash_profile located in your user’s home directory:

cd ~
nano .bash_profile

Add the following path to the composer.phar file. Replace username with your shell username:

export PATH=/home/username/.php/composer:$PATH

Save the file and close it.

Run the following to update your .bash_profile:

. ~/.bash_profile

Rename the composer file for easier handling:

mv ~/.php/composer/composer.phar ~/.php/composer/composer

Test composer:

  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 2.5.8 2023-06-09 17:13:21

Create a Drupal project with Composer

The drupal/recommended-project creates a new Drupal site with a “relocated document root”. This means that the files “index.php” and the “core” directory and so on are placed inside a subfolder named “web” rather than being placed next to “composer.json” and the “vendor” directory at the project root. This layout is recommended because it allows you to configure your webserver to only provide access to files inside the “web” directory. Keeping the vendor directory outside of the web server’s document root is better for security.

Remove the existing folder of your website, in my case, is

rm -rf

Use Composer to create a new project using the desired starter template, for this tutorial, I will use Drupal’s recommended project version 10.1.1:

composer create-project drupal/recommended-project:10.1.1

You should see the following success message:

  Congratulations, you've installed the Drupal codebase  
  from the drupal/recommended-project template!      	 

Next steps:
  * Install the site:
  * Read the user guide:
  * Get support:
  * Get involved with the Drupal community:
  * Remove the plugin that prints this message:
  	composer remove drupal/core-project-message
  * Homepage:
  * Support:
	* docs:
	* chat:

Remove the core-project-message plugin:

composer remove drupal/core-project-message

Create the configuration file and grant permissions

In the “web/sites/default” directory, copy the default.settings.php file and rename the copied file to settings.php:

cp web/sites/default/default.settings.php web/sites/default/settings.php

Give the web server write privileges (666 or u=rw,g=rw,o=rw) to the configuration file:

chmod a+w web/sites/default/settings.php

Give the web server write privileges to the web/sites/default directory:

chmod a+w web/sites/default

Create the Drupal database

In order to successfully complete the installation process, it is necessary to create an empty database for your new website.

Sign in to your DreamHost account and navigate to “Websites -> MySQL databases”. Under the “Create a New MySQL Database” section, fill out the following fields:

  • Database name: anemiadb
  • Use Hostname: Create a new hostname now…
  • New Hostname:
  • First User: Create a new user now…
  • New Username: YOUR_USERNAME
  • New Password Again: SAME SECURE PASSWORD

Click the “Add new database now!” button:

Click the Add new database now! button.

Domain directory configuration

To set the domain directory, navigate to the “Website -> Manage Website” section and click on the “Manage” button located next to your new website domain (

Click on the Manage button located next to your new website domain.

Navigate to the “Additional Settings” section and click on the “Paths” tab to access further options. In the Web directory text field, enter the path to the “web” directory of your newly created Drupal application (

Enter the path to the web directory of your newly created Drupal application.

Run the Drupal installation wizard

You are now ready to run the Drupal installation wizard. Navigate to the base URL of your website ( and follow the installation instructions.

Choose language: English

Drupal installation wizard.

Select an installation profile: Standard (Install with commonly used features pre-configured):

  • Database configuration:
    • Database type: MySQL, MariaDB, Percona Server, or equivalent.
    • Database name: anemiadb
    • Database username: YOUR DATABASE USERNAME
    • Database password: YOUR DATABASE PASSWORD
  • Database configuration – Advanced Options:
    • Host:
    • Port number: 3306

Click the “Save and Continue” button.

Once the Drupal site gets installed, the final step is to enter the site information and define the site maintenance account (User 1):

  • Site Information:
    • Site Name: Anemia
    • Site email Address:
  • Site Maintenance Account:
    • Username: your_username
    • Password: Enter a strong password
    • Confirm password
    • Email address:
  • Regional Settings:
    • Default country: United States
    • Default time zone: Denver
Enter the site information and define the site maintenance account.

Click the “Save and Continue” button.

Now you should see your new Drupal website:

Your new Drupal website.

Install Drush 12 with Composer

Login to your server via SSH and navigate to your website directory. Execute the following composer command to install Drush:

composer require drush/drush

Edit your .bash_profile file with “nano” or “vim”:

nano .bash_profile

Add the following line to your .bash_profile (Replace “” with your website directory):

alias drush='~/'

Save the changes made to your .bash_profile and exit the file. Then, use the following command to update your .bash_profile:

. ~/.bash_profile

Now you should be able to use Drush:

Newly installed Drush.

Navigate to your new Drupal application root directory ( and execute “drush status”:

drush status
astralmemories@agent-zero:~/$ drush status
Drupal version   : 10.1.1                                      	 
Site URI     	: http://default                              	 
DB driver    	: mysql                                       	 
DB hostname  	:             	 
DB port      	: 3306                                        	 
DB username  	: astralmemories                              	 
DB name      	: anemiadb                                    	 
Database     	: Connected                                   	 
Drupal bootstrap : Successful                                  	 
Default theme	: olivero                                     	 
Admin theme  	: claro                                       	 
PHP binary   	: /usr/local/php81/bin/php                    	 
PHP config   	: /etc/php81/php.ini                          	 
PHP OS       	: Linux                                       	 
PHP version  	: 8.1.17                                      	 
Drush script 	: /home/astralmemories/
Drush version	:                                    	 
Drush temp   	: /tmp                                        	 
Drush configs	: /home/astralmemories/
Install profile  : standard                                    	 
Drupal root  	: /home/astralmemories/
Site path    	: sites/default                               	 
Files, Public	: sites/default/files                         	 
Files, Temp  	: /tmp                                        	 

Congratulations on successfully installing a fresh instance of Drupal 10 using a composer-based codebase with the added functionality to execute drush commands on your Drupal site.